xcode 如何修复 NSInvalidUnarchiveOperationException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11085859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I fix NSInvalidUnarchiveOperationException
提问by Cocoa Dev
* Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*-[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (NSLayoutConstraint)'
* 由于未捕获的异常“NSInvalidUnarchiveOperationException”而终止应用程序,原因:“*-[NSKeyedUnarchiver decodeObjectForKey:]: 无法解码类的对象 (NSLayoutConstraint)”
I have a very simple app
我有一个非常简单的应用程序
One view has one button
一个视图只有一个按钮
I Control Click and dragged the button to a second view and selected MODAL
I Control 单击并拖动按钮到第二个视图并选择 MODAL
When I run it in the simulator, everything works
当我在模拟器中运行它时,一切正常
When i run it in my iPad running iOS 5.1.1, it crashes with the error above. I have no idea why and there is no code.
当我在运行 iOS 5.1.1 的 iPad 上运行它时,它会因上述错误而崩溃。我不知道为什么,也没有代码。
回答by Mike Weller
This is occuring because you are using Xcode 4.5 (or previously the beta) which uses "auto layout" by default. Auto layout is only available on iOS 6 so you will get a runtime error on previous iOS versions.
发生这种情况是因为您使用的是默认使用“自动布局”的 Xcode 4.5(或之前的测试版)。自动布局仅在 iOS 6 上可用,因此您将在以前的 iOS 版本上收到运行时错误。
You can fix this by opening your Storyboard, opening the Utilities pane, and disabling the "Use Autolayout" checkbox in the first tab/section:
您可以通过打开 Storyboard、打开 Utilities 窗格并禁用第一个选项卡/部分中的“Use Autolayout”复选框来解决此问题:
For regular non-storyboard nibs, select the top-level view to access this option.
对于常规的非故事板笔尖,请选择顶级视图以访问此选项。
回答by Appsunic
In Your Xib-> Identity and type ->Interface Builder Document -> uncheck useAutoLayout check box,this is the new feature with Ios6
在 Your Xib-> Identity and type ->Interface Builder Document -> 取消选中 useAutoLayout 复选框,这是 Ios6 的新功能