【发布时间】:2012-12-11 17:38:18
【问题描述】:
我正在尝试将 NIB/XIB 文件放在我称为 Configuration.bundle 的包中。当我尝试从我的包中加载 xib 时,应用程序崩溃,因为它找不到 xib 文件。
NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle]
pathForResource:@"Configuration" ofType:@"bundle"]];
[bundle load];
NSLog(@"bundle: %@", bundle);
我得到了输出
bundle: NSBundle(尚未加载)
“尚未加载”部分让我有点害怕。为什么没有加载?
最后,当我尝试使用视图控制器加载我的笔尖时
ConfigViewController *configViewController = [[ConfigViewController alloc] initWithNibName:@"ConfigViewController" bundle:bundle];
我得到了输出
* 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在包中加载 NIB:“NSBundle(尚未加载)”,名称为“ConfigViewController.xib”
我尝试过使用和不使用 .xib。
有什么想法吗?
【问题讨论】:
标签: objective-c ios nib nsbundle