105

Possible Duplicate:
presentViewController: crash on iOS 6 (AutoLayout)

I'm getting this error when clicking on a button in my app:

2012-06-28 21:43:36.860 AppName[2403:707] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
*** First throw call stack:
(0x3568788f 0x37a2e259 0x35687789 0x356877ab 0x333a254d 0x333a26bb 0x333a2423 0x33333001 0x332a13c7 0x3317ec59 0x330f4c17 0x330ff267 0x330ff1d5 0x3319e59b 0x3319d367 0x331f86a7 0x8fb11 0x355e13fd 0x330d6e07 0x3319c5e7 0x355e13fd 0x330d6e07 0x330d6dc3 0x330d6da1 0x330d6b11 0x330d7449 0x330d592b 0x330d5319 0x330bb695 0x330baf3b 0x3727a22b 0x3565b523 0x3565b4c5 0x3565a313 0x355dd4a5 0x355dd36d 0x37279439 0x330e9cd5 0x8f6cb 0x8f628)
terminate called throwing an exception

The error complains on this line of code:

-(IBAction) goToAbout {
    About *screen = [[ About alloc] initWithNibName:@"About" bundle:nil];
    screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:screen animated:YES];
}

The error appears only on my iPhone but not on the simulator...

Community
  • 1
  • 1
tracifycray
  • 1,423
  • 4
  • 18
  • 29

1 Answers1

263

You must uncheck the box in your NIB that says "use auto layout" before you try to run this thing on a device that doesn't support the new NSLayoutConstraint class.

enter image description here

hkulekci
  • 1,894
  • 15
  • 27
CodaFi
  • 43,043
  • 8
  • 107
  • 153
  • 14
    Also, from [this article](http://cdrussell.blogspot.in/2012/07/could-not-instantiate-class-named.html): Select the XIB which is failing to load, and from the panes down the right, find the one entitled "Interface Builder Document". Under here, are settings for deployment versions (which represents the minimum version you want to support), which can be changed to match your expectations. – Dheeraj Vepakomma Sep 28 '12 at 04:57
  • @DheerajV.S. : Why dont you add this as an answer. Quite a good link. Thanks. – Yama Sep 28 '12 at 07:13
  • @Dheeraj: In my experience, the deployment version of the XIB hardly makes a difference to the Nib unarchiver. The link is still excellent though. – CodaFi Sep 28 '12 at 12:50
  • Thanks. It worked. One totally weird thing happened after I unchecked auto-layout option. My view controller had a UITextView which was hooked on to an interface as an outlet. After doing this, that outlet kind of stopped working. There was no error. I could see the outlet functioning in the sense that its values still showed in debug console but not actually in the UI. It is now working fine after removing the view, inserting it back and recreating the outlet. – OutOnAWeekend Oct 26 '12 at 08:30
  • @CodaFi It is not a question, just a comment to inform about an oddity that showed up once I did what was told and then how found a workaround for it. It has been posted so that if anyone else stumbles on this page and finds this problem, he has some clue about what to do. – OutOnAWeekend Oct 27 '12 at 02:19
  • @CodaFi, i am always amazed when i finally check what i am considering really complicated problems that people like you know the answer. I am always trying to solve the problem myself, to learn, and google when i am not able to. You guys are unbelievable and saves my life. +1 for that – PeterK Jan 12 '13 at 12:09
  • I was in trouble. And it really helped me. Thank you thank you thank you so much. There was a problem in my live application and I had issues from app users. And now I am uploading another version of app. Thanks. – Hemang Mar 12 '13 at 09:37
  • If you are building with iOS 6 (or greater) as your base SDK, and you test on a pre-iOS 6 device/simulator, then you will get this error message. That is at least what was happening to me. – BigSauce May 07 '13 at 19:33