繁体   English   中英

为什么Xcode无法加载我的NIB

[英]Why couldn't xcode load my NIB

在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];

看起来您在情节提要中定义了视图控制器! 在这种情况下,您应该

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

DisplayWarningViewController *displayWarningVC = (DisplayWarningViewController *)[storyboard instantiateViewControllerWithIdentifier:@"DisplayWarningViewController"]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM