就像现在一样,我的应用程序很好地加载到模拟器中没有我知道的错误,但是当它运行时,它会在调试器窗口中显示以下错误而崩溃:
2010-05-31 19:44:39.703 UsingViewsActionSheet[49538:207] *** Assertion
failure in -[UIActionSheet showInView:],
/SourceCache/UIKit_Sim/UIKit-1145.66/UIAlert.m:70732010-05-31 19:44:39.705 UsingViewsActionSheet[49538:207] ***
Terminating app due to uncaught exception
‘NSInternalInconsistencyException’,reason: ‘Invalid parameter not
satisfying: view != nil
“
我确信这是应用程序基于我使用断点而中断的块.
//在加载视图后,通常从nib实现viewDidLoad以进行其他设置.
– (void)viewDidLoad {
UIActionSheet * action = [[UIActionSheet alloc]
initWithTitle:@“这是我的行动表!”
委托:自我
cancelButtonTitle:@ “OK”
destructiveButtonTitle:@“删除消息!”
otherButtonTitles:@“Option 1”,@“Option 2”,@“Option 3”,nil];
[action showInView:self.view]; // <-- This line seems to trigger the crash.... [action release]; [super viewDidLoad];
}
我错过了一些明显的东西,还是问题比这里显示的更多?我已经查看了showInView的摘要,并且还无法对其进行任何修改.
我感谢任何和所有的支持.
问候,
史蒂夫奥沙利文
解决方法
NSLog(@"View: %@; Window: %@",[self.view description],[self.view.window description]);
可能会显示窗口为null / nil.
根据您的设计,您可能只需在主线程上排队就可以了:
-(void) showMyActionSheet { UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"This is my Action Sheet!" delegate:self cancelButtonTitle:@"OK" destructiveButtonTitle:@"Delete Message!" otherButtonTitles:@"Option 1",@"Option 2",@"Option 3",nil]; [action showInView:self.view]; [action release]; } - (void)viewDidLoad { [super viewDidLoad]; [self performSelectorOnMainThread:@selector(showMyActionSheet) withObject:nil waitUntilDone:NO]; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。