异常'NSInternalInconsistencyException',原因:'无法加载捆绑中的NIB:...可以找人发现有什么问题

问题描述:

以下代码发生错误---终止应用程序由于未被捕获 异常'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

正如在您的意见中提到您使用的故事板,那么这是不是你将如何初始化的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