NSInvalidUnarchiveOperationException:无法实例化名为 NSLayoutConstraint 的类 [英] NSInvalidUnarchiveOperationException: Could not instantiate class named NSLayoutConstraint

查看:23
本文介绍了NSInvalidUnarchiveOperationException:无法实例化名为 NSLayoutConstraint 的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此很陌生.我为 iPhone 项目HelloWorld"一步一步地遵循了 Apple 的教程.我在 iPhone 5.0 模拟器中运行它,它崩溃了:

I am very new to this. I followed Apple's tutorial step by step for the iPhone project "HelloWorld". I ran it in the iPhone 5.0 simulator and it crashed:

2012-11-02 14:46:06.782 HelloWorld[9880:c07] * 终止应用到期未被抓住异常NSInvalidUnarchiveOperationException",原因:无法实例化类名为 NSLayoutConstraint'* 先抛出调用栈:(0x14a2052 0xea2d0a 0x144aa78 0x144a9e9 0x32f7d7 0x32f9af 0x32f6b7 0x23036d 0xd7e2c 0xd83a9 0xd808c 80x 308c 80x 80c 39d0x10be6 0x118a6 0x20743 0x211f8 0x14aa9 0x138cfa9 0x14761c5 0x13db0220x13d990a 0x13d8db4 0x13d8ccb 0x112a7 0x12a9b 0x1fed 0x1f15 0x1)终止调用抛出异常(lldb)

2012-11-02 14:46:06.782 HelloWorld[9880:c07] * Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint' * First throw call stack: (0x14a2052 0xea2d0a 0x144aa78 0x144a9e9 0x32f7d7 0x32f9af 0x32f6b7 0x23036d 0xd7e2c 0xd83a9 0xd85cb 0x38a73 0x38ce2 0x38ea8 0x3fd9a 0x10be6 0x118a6 0x20743 0x211f8 0x14aa9 0x138cfa9 0x14761c5 0x13db022 0x13d990a 0x13d8db4 0x13d8ccb 0x112a7 0x12a9b 0x1fed 0x1f15 0x1) terminate called throwing an exception(lldb)

谁能告诉我出了什么问题?我使用的是 Xcode 4.5.

Can someone please tell me what went wrong? I'm using Xcode 4.5.

推荐答案

默认情况下,当您在 Xcode 4.5 中创建新的 iOS 项目时,您的故事板或 XIB 会设置为使用 Autolayout,这是 iOS 6.0 中的一项新功能.NSLayoutConstraint 类是 Autolayout 系统的一部分,在旧版本的 iOS 中不存在.

By default, when you create a new iOS project in Xcode 4.5, your storyboard or XIB is set to use Autolayout, which is a new feature in iOS 6.0. The NSLayoutConstraint class is part of the Autolayout system, and it doesn't exist in older versions of iOS.

如果您想将您的应用部署到旧版本的 iOS,您需要将故事板或 XIB 更改为使用自动布局.这是文件检查器中的一个复选框:

If you want to deploy your app to an older version of iOS, you need to change your storyboard or XIB to not use Autolayout. It's a checkbox in the File Inspector:

这篇关于NSInvalidUnarchiveOperationException:无法实例化名为 NSLayoutConstraint 的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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