presentViewController:在 iOS <6 (AutoLayout) 上崩溃 [英] presentViewController: crash on iOS <6 (AutoLayout)

查看:33
本文介绍了presentViewController:在 iOS <6 (AutoLayout) 上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我遇到的一个奇怪的崩溃.当我按下转到某个 ViewController 的按钮时会发生崩溃.它崩溃的行是:

This is a weird crash I am getting. The crash happens when I press a button that goes to a certain ViewController. The line which it crashes on is:

DestinationInformationViewController *info = [[DestinationInformationViewController alloc] init];
[info setModalTransitionStyle: UIModalTransitionStyleCrossDissolve];
[self presentViewController:info animated:YES completion: nil]; // CRASHES HERE
[info release];

崩溃跟踪是:

*** 由于未捕获的异常NSInvalidUnarchiveOperationException"而终止应用程序,原因:无法实例化名为 NSLayoutConstraint 的类"*** 首先抛出调用堆栈:(0x3758288f 0x35287259 0x37582789 0x375827ab 0x3153d54d 0x3153d6bb 0x3153d423 0x314ce001 0x3143c3c7 0x31319c59 0x3128fc17 0x3129a267 0x3129a1d5 0x3133959b 0x31338367 0x84091 0x374dc3fd 0x31271e07 0x31271dc3 0x31271da1 0x31271b11 0x31272449 0x3127092b 0x31270319 0x31256695 0x31255f3b 0x33c9822b 0x37556523 0x375564c5 0x37555313 0x374d84a5 0x374d836d 0x33c97439 0x31284cd5 0x82bb3 0x71200)终止调用抛出异常(gdb)无法实例化名为 NSLayoutConstraint 的类

注意:这会在我的 iPhone 4 iOS 5.1 上崩溃,但不会在我的 iPhone 4S iOS 6 Beta 2 上崩溃

NOTE: This crashes on my iPhone 4 iOS 5.1 but not on my iPhone 4S iOS 6 Beta 2

推荐答案

我认为这是 Xcode 新界面构建器的问题.您是否碰巧使用 Xcode 4.5 的界面构建器构建了 .xib?我刚才遇到了同样的问题,我认为这就是问题所在.我的应用在 iOS 6 上运行,但不是旧版本.

I believe this is an issue with Xcode's new interface builder. Did you happen to build your .xib using Xcode 4.5's interface builder? I've run into this same problem just now, and I think that's the problem. My app runs on iOS 6, but not anything older.

并且您需要确保为您的 xib 关闭使用自动布局.

And you need to make sure you turn off Use Auto Layout for your xibs.

这可以通过:

  1. 打开你的 xib.
  2. 转到文件检查器标签.
  3. 在右侧工具栏上找到 Interface Builder Document 部分.
  4. 取消选中使用自动布局选项.
  1. Open your xib.
  2. Go to the File Inspector tab.
  3. Find the Interface Builder Document section on the right toolbar.
  4. Uncheck the Use Auto Layout option.

这篇关于presentViewController:在 iOS <6 (AutoLayout) 上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆