【发布时间】:2012-04-23 12:07:07
【问题描述】:
我用我的自定义UIViewController 子类初始化UINavigationController。但只要我想展示视图控制器,我就会在 Xcode 中收到 SIGABRT 错误。我以前做过很多次,我认为这个问题的存在是因为在我当前的项目中可能不正确的其他事情。但是,我发现很难找到这种现象背后的问题。那么,您可以做些什么来阻止模态视图控制器的呈现?
这就是我展示视图控制器的方式:
- (IBAction)tutorialTouched:(id)sender {
TutorialViewController *tutorialVC = [[TutorialViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:tutorialVC];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
// This line leads to `SIGABRT`
[self presentModalViewController:nav animated:NO];
}
部署目标是 5.0。
更新:
这是我在控制台中输入bt 时得到的信息:
#0 0x945919c6 in __pthread_kill ()
#1 0x9645bf78 in pthread_kill ()
#2 0x9644cbdd in abort ()
#3 0x003169dc in uncaught_exception_handler ()
#4 0x032010fc in __handleUncaughtException ()
#5 0x02f00f0f in _objc_terminate ()
#6 0x0349e8de in safe_handler_caller ()
#7 0x0349e946 in std::terminate ()
#8 0x0349fb3e in __cxa_rethrow ()
#9 0x02f00e15 in objc_exception_rethrow ()
#10 0x03137de0 in CFRunLoopRunSpecific ()
#11 0x03137c9b in CFRunLoopRunInMode ()
#12 0x035ca7d8 in GSEventRunModal ()
#13 0x035ca88a in GSEventRun ()
#14 0x016b3626 in UIApplicationMain ()
#15 0x00002fad in main (argc=1, argv=0xbffff5a8) at /Users/myProject/main.m:14
【问题讨论】:
-
控制台中的内容是什么?
-
能否在您的 Xcode 调试器控制台中提供详细的错误信息?如果应用程序以 SIGABRT 退出,则应该有一些关于异常的信息。如果您使用的是 iOS 4.x 模拟器,则一个可能的例外是
NSInvalidArgumentException。 -
可能问题是块(完成)是空的。尝试在其中放入一些虚拟代码(NSLog)。
-
@kuba 我用传统方法更新了我的答案,这也不起作用。
-
这段代码属于什么类?它甚至是 UIViewController 吗?
标签: objective-c ios xcode ipad sigabrt