【问题标题】:Error showing when i opening my xib file打开我的 xib 文件时显示错误
【发布时间】:2013-05-05 03:48:39
【问题描述】:

当我单击 tableview 行时,我使用以下代码打开 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) 

【问题讨论】:

  • ViewController 的 viewDidLoad 和 viewWillAppear 方法里面有什么?
  • 有默认代码

标签: ios uiviewcontroller uinavigationcontroller xib


【解决方案1】:

这是因为您使用的是默认使用“自动布局”的 Xcode 4.5+(或以前的测试版)。自动布局仅在 iOS 6 上可用,因此在以前的 iOS 版本上会出现运行时错误。

您可以通过打开 Storyboard、打开“实用工具”窗格并禁用第一个选项卡/部分中的“使用自动布局”复选框来解决此问题:

对于常规的非故事板笔尖,选择顶级视图以访问此选项。

【讨论】:

  • iam 使用 xcode 4.6 .2 但那里的 autolay ios。现在我取消检查它,让我试试
【解决方案2】:

您在 IB 中使用自动布局设计了视图,但您试图在 ios5 设备或模拟器上运行代码?

编辑:对,iOS5 中不存在该类!如果你想让这个应用程序在 iOS5 中运行,你需要将 xib 从 AutoLayout 转换回 springs 和 struts。每个 XIB 中的右侧检查器视图中都有一个复选框来执行此操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-19
    • 2016-11-29
    • 2018-12-29
    相关资源
    最近更新 更多