2013-06-12 103 views
1

我正在開發一個通用應用程序。它在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文件放在捆綁資源中。

回答

1

此問題可能是由您的xib文件的名稱引起的。您沒有名爲MemberBenefitsipad的xib。

如果對於iPhone和iPad的視圖控制器,有不同的xib文件將這些文件命名爲「MyXibFile〜ipad.xib」(適用於iPad)和「MyXibFile〜iphone.xib」適用於iPhone,當您嘗試加載xib只使用「MyXibFile」字符串而不是整個名稱,這樣操作系統將根據設備加載所需的xib。

另外要小心絲毫的資源和廈門國際銀行的命名,因爲模擬器不區分大小寫(MyXibFile = myxibfile),但該設備是區分大小寫(MyXibFile!= myxibfile)

相關問題