我正在開發一個通用應用程序。它在iPhone和iPad模擬器上以及iPhone 4S上都運行良好,但它在iPad上崩潰。這是iPad上的分割視圖,只有在打開某些視圖時纔會崩潰。有些視圖工作得很好,沒有問題,但是在其他視圖中選擇主視圖中的特定行以顯示詳細視圖中的新視圖時,它會崩潰。如果我在iPad模擬器上運行它,那麼有問題的視圖可以打開。有任何想法嗎?應用程序在設備上崩潰但不在模擬器上
以下是我在主視圖中選擇其行時在詳細視圖中顯示問題視圖之一的方式。我在這個視圖中有一個搜索欄,搜索欄出現,但地圖視圖沒有。再次,iPad模擬器上的一切都運行良好。
else if (indexPath.row == 8)
{
RSFMipad *rsfm = [[RSFMipad alloc]initWithNibName:nil bundle:nil];
NSMutableArray *details = [self.splitViewController.viewControllers mutableCopy];
UINavigationController *detailNav = [[UINavigationController alloc]initWithRootViewController:rsfm];
[details replaceObjectAtIndex:1 withObject:detailNav];
KFBAppDelegate *appDelegate = (KFBAppDelegate *)[[UIApplication sharedApplication]delegate];
appDelegate.splitViewController.viewControllers = details;
appDelegate.window.rootViewController = self.splitViewController;
appDelegate.splitViewController.delegate = rsfm;
[appDelegate.splitViewController viewWillAppear:YES];
}
這裏是另一個我從主視圖中的不同行加載另一個。這個不會立即填充詳細視圖,而是在主視圖中加載新的表視圖。這個也會導致iPad崩潰,但不會在模擬器中崩潰。
else if (indexPath.row == 6)
{
MemberBenefitsipad *benefits = [[MemberBenefitsipad alloc] initWithNibName:@"MemberBenefitsipad" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:benefits animated:YES];
}
,顯示日誌中的錯誤錯誤是:
2013-06-12 14:36:54.267 KFBNewsroom[12125:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/ED63F1DA-31C8-4FC1-81D7-A3DCE3186C98/KFBNewsroom.app> (loaded)' with name 'MemberBenefitsipad''
編輯:我解決了這個問題。我只需要將xib文件放在捆綁資源中。