应用程序在dismissViewControllerAnimated崩溃:

时间:2012-12-01 18:14:39

标签: objective-c ios uiviewcontroller presentmodalviewcontroller

我有一个常规的视图控制器,它试图通过 presentViewController 呈现控制器,或者使用UINavigationController推送控制器。

当我通过UINavigationController调用 dismissViewControllerAnimated:方法或单击后退按钮时,应用程序将崩溃并出现以下错误:

012-12-01 13:09:15.789 stats[12370:c07] *** Assertion failure in -[NSLayoutConstraint constant], /SourceCache/Foundation_Sim/Foundation-992/Layout.subproj/NSLayoutConstraint.m:560
2012-12-01 13:09:15.790 stats[12370:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '(null)'
*** First throw call stack:
(0x4ac012 0x1974e7e 0x4abe78 0x140af35 0x15253a2 0x1527cda 0x15274f1 0xdf4bbe 0xdf4da7 0x908be4 0x90905d 0x90905d 0x90905d 0x90905d 0x90905d 0x90905d 0x90905d 0x90905d 0x90905d 0x9045e6 0x90aaf4 0x902eed 0x97cad6 0xba9f44 0xba94eb 0x9a7a11 0x9a6ecd 0x9a6ecd 0x9a7bdb 0xa72739d 0x2e7b0 0xd71b5 0xd6f38 0xd8a19 0x4a01bd 0x4a00d6 0x4a024a 0xe27d69 0xe2913e 0x49bcf9 0x49b94e 0x4a01bd 0x4a00d6 0x4a024a 0xe27d69 0xe279da 0x49bcf9 0x49b94e 0x4a01bd 0x4a00d6 0x4a024a 0xe27d69 0xddb0a7 0x49bcf9 0x49b94e 0x4a01bd 0x4a00d6 0x4a024a 0xe27d69 0xe010cf 0x514753f 0x5159014 0x51497d5 0x452af5 0x451f44 0x451e1b 0x240c7e3 0x240c668 0x8bc65c 0x1e34d 0x2215)
libc++abi.dylib: terminate called throwing an exception

在模拟器和设备上都会发生这种情况。

以下是我如何呈现控制器:

的UINavigationController

ChartViewController *chartViewer = [[ChartViewController alloc] initWithNibName:@"ChartViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:chartViewer animated:YES];

presentViewController:

ChartViewController *chartViewer = [[ChartViewController alloc] initWithNibName:@"ChartViewController" bundle:[NSBundle mainBundle]];
[self presentViewController:chartViewer animated:YES completion:nil];

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

这可能是由新XCode上的自动布局功能引起的。

检查您的XIB是否启用了使用自动布局功能。如果是,请禁用并再次尝试: enter image description here