当我点击表格 View 行时,我使用以下代码打开xib
ViewController *List=[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[self.navigationController pushViewController:List animated:YES];
我得到了这个异常
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
*** First throw call stack:
(0x245e052 0x1731d0a 0x2406a78 0x24069e9 0xbbe7d7 0xbbe9af 0xbbe6b7 0xabf36d 0x966e2c 0x9673a9 0x9675cb 0x967941 0x97947d 0x97966f 0x97993b 0x97a3df 0x97a986 0x97a5a4 0x41b08 0x93171d 0x931952 0x11b986d 0x2432966 0x2432407 0x23957c0 0x2394db4 0x2394ccb 0x391a879 0x391a93e 0x8a1a9b 0x28dd 0x2805)
terminate called throwing an exception(lldb)
最佳答案
发生这种情况是因为您使用的是 Xcode 4.5+(或之前的测试版),它默认使用“自动布局”。自动布局仅在 iOS 6 上可用,因此您将在以前的 iOS 版本上收到运行时错误。
您可以通过打开 Storyboard、打开实用程序 Pane 并禁用第一个选项卡/部分中的“使用自动布局”复选框来解决此问题:
对于常规 Non-Storyboard Nib ,选择顶级 View 以访问此选项。
关于ios - 打开 xib 文件时显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16482610/