【问题标题】:uiactionsheet heightuiactionsheet 高度
【发布时间】:2012-04-20 08:04:24
【问题描述】:

我有一个关于 UIActionSheet 的简单问题!如何设置 UIActionsheet 的高度?我试过 setFrame 和 setBounds 但没有任何效果。我正在使用以下操作表:

NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
    UIActionSheet *actionSheet = [[UIActionSheet alloc] 
                                  initWithTitle:[NSString stringWithFormat:@"%@%@", title, NSLocalizedString(@"", @"")]
                                  delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Button1",@"Button2", nil];
    [actionSheet setTag: 1];
    //[actionSheet setBounds:CGRectMake(0,0,320,150)];
    //[actionSheet showFromRect:CGRectMake(0,0,100,50) inView: self.parentViewController.tabBarController.view animated:YES];
   // [actionSheet setFrame:CGRectMake(0, 30, 320, 30)];
    actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
    [actionSheet showInView:self.parentViewController.tabBarController.view];
     actionSheet = nil;

我的问题是操作表高度等于当前视图的高度。我想根据 UIActionSheet 的内容自动调整高度。

提前致谢,

【问题讨论】:

    标签: iphone ios uiactionsheet


    【解决方案1】:

    UIActionSheet 的默认行为是自动调整到其内容大小。你不应该直接设置frame

    您看到操作表占用了如此多的空间,因为您在标题中插入了一堆换行符,迫使标题标签占用了比应有的更多的垂直空间。如果您不希望操作表那么高,请不要这样修改标题。

    【讨论】:

    • @RamaBoya,没问题。至少您在问题中包含了换行符...否则将无法回答。
    猜你喜欢
    • 1970-01-01
    • 2011-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多