如何修复NSInvalidUnarchiveOperationException [英] How can I fix NSInvalidUnarchiveOperationException

查看:136
本文介绍了如何修复NSInvalidUnarchiveOperationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原因:'* - [NSKeyedUnarchiver decodeObjectForKey:]:无法解码类的对象(NSLayoutConstraint)'



我有一个非常简单的应用程序



一个视图有一个按钮



我控制点击并将按钮拖到第二个视图并选择MODAL



当我在模拟器中运行它时,一切正常工作



当我在运行iOS 5.1.1的iPad中运行它时,会崩溃上面的错误。我不知道为什么没有代码。

解决方案

这是因为您使用Xcode 4.5(或之前的beta ),它默认使用自动布局。自动布局仅适用于iOS 6,因此您将在以前的iOS版本中收到运行时错误。



您可以通过打开故事板,打开实用程序窗格和禁用第一个选项卡/部分中的使用自动布局复选框:





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


* Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '* -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (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

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.

解决方案

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.

You can fix this by opening your Storyboard, opening the Utilities pane, and disabling the "Use Autolayout" checkbox in the first tab/section:

For regular non-storyboard nibs, select the top-level view to access this option.

这篇关于如何修复NSInvalidUnarchiveOperationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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