[英]ABPeoplePickerNavigationController crashed while presentviewcontroller
[英]PresentViewController crashed my app
當我嘗試通過UIAlertview按鈕顯示ViewController時,出現了一個非常奇怪的錯誤。 它在prsentViewController行上崩潰了。 Backtrace顯示它無法加載view。 我怎樣才能解決這個問題? 源代碼如下:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView == _alertView) {
switch (buttonIndex) {
case 0:
{
[alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
}
break;
default:
{
NSString *nibName = IS_IPAD? NSStringFromClass([UINewUserAccountViewController class]) : [NSStringFromClass([UINewUserAccountViewController class]) stringByAppendingString:@"~iPhone"];
UINewUserAccountViewController *newUserAccountViewController = [[UINewUserAccountViewController alloc] initWithNibName:nibName bundle:nil];
newUserAccountViewController.delegate = self;
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:newUserAccountViewController];
[self presentViewController:navi animated:YES completion:nil];
}
break;
}
}
}
在@rckoenes的幫助下,遇到異常幾次后,我終於找到了錯誤。 它在UIViewController loadFromNibName處停止,因為該行
[NSStringFromClass([UINewUserAccountViewController class]) stringByAppendingString:@"~iPhone"]
返回筆尖名稱,但在具有該名稱的xib文件中,根視圖不是文件出口。 將視圖鏈接到文件出口后,異常消失了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.