为什么UIActionSheet不支持我的风景?

时间:2013-02-07 02:03:08

标签: iphone ios objective-c uiactionsheet

我有一个带有tabbarcontroller的应用程序,带有两个控制器,现在在一个控制器中我在肖像模型中显示了一个uiactionsheet:

UIActionSheet * actionSheet = [[UIActionSheet alloc]                    initWithTitle:@ “”                    delegate:nil cancelButtonTitle:@“取消”                                   destructiveButtonTitle:@ “删除”                    otherButtonTitles:无,无];

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

我发现当我将模式更改为横向时,它不起作用,因为它不响应控制器委托:

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

如果动作表没有显示,控制器可以改变景观,为什么?非常感谢!!!

1 个答案:

答案 0 :(得分:3)

试试这个:

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];
  }