Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
224 views
in Technique[技术] by (71.8m points)

objective c - NSInvalidUnarchiveOperationException: Could not instantiate class named NSLayoutConstraint

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] * 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)

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

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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:

turning off autolayout


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...