iphone - 为什么 UIActionSheet 不支持我的横向?

标签 iphone ios objective-c uiactionsheet

我有一个带有 tabbarcontroller 的应用程序,有两个 Controller ,现在在一个 Controller 中,我在纵向模型中显示了一个 uiactionsheet:

UIActionSheet *actionSheet = [[UIActionSheet 分配] 初始化标题:@“” 委托(delegate):无 cancelButtonTitle:@“取消” destructiveButtonTitle:@"删除" 其他按钮标题:无,无];

actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[actionSheet showInView:self.view];
actionSheet.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
[actionSheet release];

我发现当我将模式更改为横向时,它不起作用,因为它不响应 Controller 委托(delegate):

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

如果操作表不显示, Controller 可以更改为横向,为什么?非常感谢!!!

最佳答案

试试这个:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Some text..."
                           delegate:self
                  cancelButtonTitle:@"Cancel"
             destructiveButtonTitle:@"Delete"
                  otherButtonTitles:@"Button 1",@"Button 2",nil];

  if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.0 ||
      UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])) {
    [sheet showInView:self.view];
  } else {
    [sheet showInView:self.view.window];
  }

关于iphone - 为什么 UIActionSheet 不支持我的横向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14742335/

相关文章:

iphone - 如何使用 objective c 使 iPhone 进入静音模式开/关

iphone - 不允许应用访问 UDID

javascript - iframe 中的 WKWebView 本地文件

ios - 用于签署 “APP” 的证书已过期或已被吊销 - ios10

Objective-C:使用静态变量

iphone - 在 iPhone 中使用 MKPolygon 创建给定点的轮廓

javascript手指滑动检测

ios - 在 uitableviewcell 内的 Collection View 中添加属性

ios - 在 CoreData 之外使用自动生成的模型文件对象

ios - 是否可以在屏幕锁定的情况下为 iPhone 使用用户定义的通知声音?