error occurs with below code---Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:
- (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];
}
最佳答案
正如您在评论中提到的,您正在使用 Storyboard,那么这不是您使用 Storyboard 初始化 UIViewController 对象的方式。
你必须这样创建对象
DetailViewController *vcDetailViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"DetailViewController"];
vcDetailViewController.index = indexPath.row;
[self.navigationController pushViewController:vcDetailViewController animated:YES];
此外,您需要将 StoryBoard Id 提供给您的 View Controller ,检查图像
关于ios - 异常 'NSInternalInconsistencyException' ,原因 : 'Could not load NIB in bundle: . ..有人可以找出这有什么问题吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40882272/