繁体   English   中英

从资源包中加载本地化的xib文件(不是主要的)

[英]Loading localized xib file from resource bundle (not main)

我使用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”,原因:“无法在捆绑包中加载NIB:“ NSBundle(尚未加载)”,名称为

我已经打印出了nibBundle中的文件,并且文件在那里。

我刚刚在Apple Developer网站上看到

在UIKit中,应用程序只能从其主捆绑包中加载nib文件,因此需要的选项更少。 但我想知道是否还有其他选择。

暂无
暂无

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

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