2013-05-13 49 views
1

此代碼在我的「設置」選項卡內的導航視圖中調用。它在iOS 5.1的最後一行崩潰,但是不是 iOS 6.爲什麼?爲什麼此代碼在iOS 5.1中崩潰但不是iOS 6?

else if (indexPath.section == 0 && [[settingsArray objectAtIndex:indexPath.row] isEqualToString:@"Unlock Premium Features"]) 
    { 
     InAppViewController *inappController = [[InAppViewController alloc] initWithNibName:@"InAppViewController" bundle:nil]; 
     inappController.titleString = @"Upgrade to Pro."; 
     EditNavController *navController = [[EditNavController alloc] initWithRootViewController:inappController]; 
     [self.navigationController presentModalViewController:navController animated:NO]; 
    } 

它崩潰上:

[self.navigationController presentModalViewController:navController animated:NO]; 

這裏是崩潰:

*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint' 
+1

任何特定的crash mes鼠尾草/堆棧跟蹤/任何東西? – 2013-05-13 19:19:23

+1

它在'presentModalViewController'行崩潰了嗎? – Popeye 2013-05-13 19:21:06

+1

你確定這不是相反嗎? 'presentModalViewController'在iOS 6中已被棄用。它可以被presentViewController替代:animated:completion。 (http://stackoverflow.com/questions/12507455/a-lot-of-functions-are-deprecated-ios-6) – leanne 2013-05-13 19:25:11

回答

13

如果您正在使用自動佈局(如果你創建了一個新的筆頭它在默認情況下),在視圖中它會崩潰,因爲自動佈局僅在ios 6中引入。this is how to disable it

+0

謝謝你展示如何禁用它。這是我認爲有一個愚蠢的按鈕,有勾選標記,它正在崩潰我的整個設置。謝謝! – 2013-05-13 19:27:43

+0

沒問題,把它標記爲答案然後 – Fonix 2013-05-13 19:28:52

+3

還是要等2分鐘才說。別擔心,我會的。 :) – 2013-05-13 19:29:12