2016-11-30 128 views
1

以下代碼發生錯誤---終止應用程序由於未被捕獲 異常'NSInternalInconsistencyException' ,原因是:「不能在包中加載 NIB:異常'NSInternalInconsistencyException',原因:'無法加載捆綁中的NIB:...可以找人發現有什麼問題

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
       DetailViewController *dvc =[[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil]; 
       dvc.index = indexPath.row; 
       [self.navigationController pushViewController:dvc animated:YES]; 

       } 
+0

是包含在你的目標筆尖文件(檢查Xcode右側的文件屬性窗格,並確保該框被選中)? – par

+0

提到這個名字是propabrly,例如DetailViewController.xib –

+0

檢查這個 - http://stackoverflow.com/questions/5337337/could-not-load-nib-in-bundle – Rajat

回答

1

正如在您的意見中提到您使用的故事板,那麼這是不是你將如何初始化的UIViewController對象與故事板。

你必須這樣

DetailViewController *vcDetailViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"DetailViewController"]; 
vcDetailViewController.index = indexPath.row; 
[self.navigationController pushViewController:vcDetailViewController animated:YES]; 

創建對象此外,你需要給故事板編號到您的視圖控制器,檢查圖像

enter image description here

+0

我已經提到你需要將故事板ID提供給你的控制器 – Rajat

相關問題