【发布时间】:2015-06-03 00:14:41
【问题描述】:
我使用 CocoPad 创建了一个资源包,其中包含本地化字符串、图像和 xib 文件。我在加载本地化字符串和图像时没有问题,但我在使用类似方法加载 xib 文件时遇到问题。这是我尝试过的一种方法:
NSString *nibName = @"MyTestViewController";
NSBundle *resourceBundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"MyTestResources" withExtension:@"bundle"]];
NSString* path= [resourceBundle pathForResource:@"en" ofType:@"lproj"];
NSBundle* nibBundle = [NSBundle bundleWithPath:path];
return [[MyTestViewController alloc] initWithNibName:nibName bundle:nibBundle];
我得到了 'NSInternalInconsistencyException',原因:'Could not load NIB in bundle: 'NSBundle (not yet loaded)' with name
我已经把nibBundle中的文件打印出来了,文件就在那里。
【问题讨论】:
标签: ios objective-c localization cocoapods