尝试调试“-[UIActionSheet showInView:]”中的“断言失败”错误
我正在学习“开始 iPad 应用程序开发”,并在第 3 章中陷入困境,在第 3 章中我创建了一个与操作表一起使用的项目。
就目前而言,我的应用程序加载到模拟器中效果很好,没有我意识到的错误,但当它运行时,它崩溃并在调试器窗口中显示以下错误:
2010-05-31 19:44:39.703 使用ViewsActionSheet[49538:207] *** 断言 -[UIActionSheet showInView:] 失败, /SourceCache/UIKit_Sim/UIKit-1145.66/UIAlert.m:7073
2010-05-31 19:44:39.705 使用ViewsActionSheet[49538:207] *** 由于未捕获的异常而终止应用程序 'NSInternalInconsistencyException',原因:'无效参数 令人满意:查看!= nil
'
我确信这是应用程序根据我对断点的使用而中断的块。
//实现viewDidLoad
在加载视图后进行额外的设置(通常是从笔尖加载)。
<代码> - (void)viewDidLoad { UIActionSheet *action = [[UIActionSheet 分配] initWithTitle:@“这是我的操作表!” 代表:自己 取消按钮标题:@“确定” virtualButtonTitle:@“删除消息!” otherButtonTitles:@"选项 1", @"选项 2", @"选项 3", nil];
[action showInView:self.view]; // <-- This line seems to trigger the crash....
[action release];
[super viewDidLoad];
} 我是否
遗漏了一些明显的东西,或者问题是否比此处显示的更多?我已经查看了 showInView 的摘要,但还无法预测其中的任何内容。
我感谢任何和所有的帮助。
问候,
史蒂夫·奥沙利文
I am working through "Beginning iPad Application Development" and am getting hung up in Chapter 3 where I have created a project that works with an Action Sheet.
As it stands now, my application loads into the simulator just fine with no errors that I am aware of, but as it runs, it crashes with the following errors showing up in the debugger window:
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
'
I am sure that this is the block where the app breaks based upon my use of breakpoints.
//Implement viewDidLoad
to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
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]; // <-- This line seems to trigger the crash....
[action release];
[super viewDidLoad];
}
Am I missing something obvious, or is there more to the problem than is shown here? I have looked at the abstract for showInView and cannot divine anything there yet.
I appreciate any and all asssitance.
Regards,
Steve O'Sullivan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 viewDidLoad 方法中,视图并未完全设置。窗口属性未连接。
可能会显示窗口为 null/nil。
根据您的设计,您可能会幸运地简单地将其在主线程上排队:
Within the viewDidLoad method the view is not setup entirely. The window property is not wired up.
will probably show that window is null/nil.
Depending on your design, you may have luck with simply queueing it on the main thread:
我刚刚遇到了同样的问题。
我正在将现有的 iPhone 应用程序转换为通用运行。
我有几个名为 UIAlertViews 的按钮工作正常,但我有一个调用操作表的按钮。
它产生了同样的错误。在我的视图控制器中的 ipadview.xib 的 IB 中,当我应该将其链接到按钮时,我将“视图”错误链接到了窗口。
现在效果很好。
希望这有帮助。
(ps,我是一个完全的新手,所以如果这没有帮助,请原谅)
尼尔
I've just had the same problem.
I was converting an existing iPhone app to run universal.
I have several buttons that called UIAlertViews that work fine but I have a button that calls an actionsheet.
It was generating the same error. In IB in my ipadview.xib in my view controller i had mislinked "view" to window when i should have linked it to the button.
It now works fine.
Hope this helps.
(ps im a complete novice so forgive if this doesnt help)
Neil
我刚刚完成了同一章,本书的作者在这里解决了这个问题 http://p2p.wrox.com/book-beginning-ipad-application-development/79379-ch-3-usingviews-alert-actionsheet.html 但如果如果是你,我会投票选择 Eiko 的响应作为答案,因为它实现了示例所需的行为,而作者让你创建一个按钮,在应用程序启动后单击该按钮即可查看工作表。
I was just working through the same chapter and the book's author addresses it here http://p2p.wrox.com/book-beginning-ipad-application-development/79379-ch-3-usingviews-alert-actionsheet.html though if I were you I would vote Eiko's response as the answer since it accomplishes the behavior the example is going for, whereas the authors has you create a button that you clicked after the application launches to see the sheet.
对于后来接触此主题的人来说,这仍然是 5.0 (9A334) iPad 模拟器和物理设备 (iPad) 中的问题。
Eiko 的答案仍然正确。
Just for any late comers to this topic, this is still an issue in 5.0 (9A334) iPad simulator and physical devices (iPads).
The answer by Eiko remains correct.
我最近修复了
ActionSheet
的断言失败,如下所示:它对我来说效果很好。
I have fixed assertion failure for
ActionSheet
recently like this:It works fine for me.