UIActionSheet showInView上的iPad NSInternalInconsistencyException

时间:2011-02-25 22:07:56

标签: objective-c ipad ios uiactionsheet

在我的通用iPhone / iPad应用程序中,当我尝试在模态视图中显示操作表时,我只在iPad上崩溃。当我在主视图中时它不会崩溃。这个过程类似于:

(用户点击按钮以显示模态视图)

-(IBAction)showModal:(id)sender {
    modalController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:modalController animated:YES];
}

(然后,在指定的时间,调用一个函数,然后调出一个UIActionSheet)

actionSheet = [[UIActionSheet alloc] initWithTitle:@"Alarm"
                                        delegate:self
                               cancelButtonTitle:nil
                          destructiveButtonTitle:@"Dismiss"
                                   otherButtonTitles:nil];
[actionSheet showInView:self.view];

这给了我以下错误:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: view != nil'

有没有人知道我为什么只在iPad上收到此错误?谢谢!

1 个答案:

答案 0 :(得分:0)

你不应该使用?:

UIActionsheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Alarm"
                                    delegate:self
                           cancelButtonTitle:nil
                      destructiveButtonTitle:@"Dismiss"
                               otherButtonTitles:nil];

[actionSheet showInView:[self view]];