我試圖讓彈出窗口出現在按下按鈕的ios 8中,但應用程序在按下按鈕時崩潰。我已經設置了正確的所有故事板,並使用斷點我決定在這條線,導致即使這是爲了顯示在酥料餅的視圖控制器是FirstViewController類的問題:當出現彈出窗口時應用程序崩潰
UIViewController *vc = destNav.viewControllers.firstObject;
這是崩潰:
***終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是: ' - [SecondViewController viewControllers]:無法識別的選擇發送到實例0x1446ea3a0'
這是休息我的代碼從該部分:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Assuming you've hooked this all up in a Storyboard with a popover presentation style
if ([segue.identifier isEqualToString:@"popover"]) {
UINavigationController *destNav = segue.destinationViewController;
FirstViewController *vc = destNav.viewControllers.firstObject;
// This is the important part
UIPopoverPresentationController *popPC = destNav.popoverPresentationController;
popPC.delegate = self;
}
}
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}
最有可能的'destNav.viewControllers.firstObject'是'nil'。你可以在你的問題中發佈錯誤消息嗎? – 2014-11-03 21:29:09
發佈有關崩潰的詳細信息。究竟是哪條線崩潰?什麼是崩潰的完整和準確的錯誤信息? – rmaddy 2014-11-04 00:59:15
我已將錯誤消息添加到問題中,並且確切的線路是在最初的問題中。 – newbie 2014-11-04 07:25:25