无法在捆绑中加载NIB

Tim*_*Tim 4 iphone xcode objective-c

*由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'无法在bundle中加载NIB:'NSBundle(loaded)',名称为'ViewLecturer'

ViewLecturer *viewLecturer = [[ViewLecturer alloc]initWithNibName:@"ViewLecturer" bundle:nil];

[self.navigationController pushViewController:viewLecturer animated:YES];
Run Code Online (Sandbox Code Playgroud)

我检查了文件类型,它是file.xib.
双重检查xib名称是ViewLecturer但我仍然经常在设备上得到错误.虽然在刺激器上工作正常.

小智 11

ViewLecturer *viewLecturer = [[ViewLecturer alloc]
                              initWithNibName:@"ViewLecturer" bundle:nil];
Run Code Online (Sandbox Code Playgroud)

你必须要处理两件事:

  1. 此调用假定您有一个名为"ViewLecturer.xib"而不是"file.xib"的文件
  2. 确保该文件包含在应用程序包中.检查构建阶段>将ressources复制到bundle.

  • 无论如何,谢谢,我将文件重命名为另一个名称,并将其更改回来并正常工作.我想有些错误. (2认同)

vis*_*kh7 6

确保使用正确的文件名,iOS区分大小写,而模拟器则不区分大小写.所以,如果它在模拟器中工作,但在设备上没有,请检查文件名上的情况......