在 XCode 中运行程序时,我收到以下错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/user/Library/Developer/CoreSimulator/Devices/646F9805-AC4E-40A8-BC62-75B92339DCDC/data/Containers/Bundle/Application/D6C27367-F61B-4CAC-BB9E-1D48227CE629/WhatsNap.app> (loaded)' with name 'DisplayWarningViewController''
我正在运行以下几行代码,但在最后一行出现异常。我不确定为什么会这样。关于此主题的其他答案表明 nib 文件可能未连接?
DisplayWarningViewController* DWVC = [[DisplayWarningViewController alloc]initWithNibName:@"DisplayWarningViewController" bundle:nil];
DWVC.delegate = self;
[self presentViewController:DWVC animated:NO completion:nil];
最佳答案
看起来你在 Storyboard中定义了 View Controller !在那种情况下你应该做
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
DisplayWarningViewController *displayWarningVC = (DisplayWarningViewController *)[storyboard instantiateViewControllerWithIdentifier:@"DisplayWarningViewController"]
关于ios - 为什么 xcode 无法加载我的 NIB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26878490/