当前位置:  开发笔记 > IOS > 正文

UIActionSheet在iPad /非iPhone上崩溃

如何解决《UIActionSheet在iPad/非iPhone上崩溃》经验,为你挑选了1个好方法。

当我查看控制台时,我收到此消息

2010-09-18 17:04:05.284 Wasted Time[8998:207] *** Assertion failure in -[UIActionSheet showInView:], /SourceCache/UIKit_Sim/UIKit-1145.66/UIAlert.m:7073
2010-09-18 17:04:05.286 Wasted Time[8998:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: view != nil'
2010-09-18 17:04:05.286 Wasted Time[8998:207] Stack: (
    42272848,
    43430700,
    42010379,
    811796,
    3796273,
    3862560,
    9631,
    3616645,
    3688229,
    3682846,
    3690662,
    3686119,
    4983946,
    71264534,
    71263781,
    71207378,
    71206706,
    3003734,
    3030334,
    3011831,
    3043800,
    51265916,
    41552028,
    41547944,
    3002913,
    3036018,
    8314
)
terminate called after throwing an instance of 'NSException'

代码如下:

- (void)viewDidLoad {
    BOOL    continueYesNo;
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    continueYesNo = [prefs boolForKey:@"keyContinueMeeting"];   
    if (continueYesNo) {
        NSString *message_continue = [[NSString alloc] initWithFormat:@"Do you want to Continue the Prior Meeting"];
        UIActionSheet *actionSheet = [[UIActionSheet alloc] 
            initWithTitle:message_continue 
            delegate:self
            cancelButtonTitle:@"Reset" 
            destructiveButtonTitle:@"Continue"
            otherButtonTitles:nil];
        [actionSheet showInView:self.view];
        [actionSheet release];
        [message_continue release];
    }
}

它在iPhone和iPhone模拟器中运行良好,但在iPad模拟器中崩溃.



1> Shaggy Frog..:

错误消息说:

无效参数不满足:view!= nil

可能来自这条线:

[actionSheet showInView:self.view];

既然你说这适用于iPhone而不是iPad,那就意味着iPad到达这条线的代码路径可能与iPhone到达这条线所需的代码路径不同.这意味着view可能没有为iPad设置视图控制器的属性.

我的猜测:你忘了view在Interface Builder中为这个视图控制器正在使用的xib的iPad版本连接插座.


好的..我想出来了 - [actionSheet showInView:self.parentViewController.view];
推荐阅读
mobiledu2402851173
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有