iphone - uiactionsheet 高度

标签 iphone ios uiactionsheet

我有一个关于 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;

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

提前致谢,

最佳答案

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

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

关于iphone - uiactionsheet 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10238179/

相关文章:

iphone - 将 Twitter 集成到 iOS 4.3+ 应用程序中

ios - UIKit-Swift 自定义 UIButton 不会触发点击 Action

objective-c - Objective-C : Where to #import protocol header files

iphone - UIActionSheet,取消按钮运行方法

iOS ActionSheet 的 Android 等效

iphone - MPMoviePlayerController 进入黑屏

iphone - iOS,使用下划线与直接使用 iVar

javascript - 如何让 jQuery UI 的 Draggable 和 Sortable 功能在 iPhone 上运行?

ios - iOS 上的 "You are creating QApplication before calling UIApplicationMain"错误

ios - 更改 MessageUI 表单和 ActionSheet 的语言