0

似乎我的 nib 文件包含在我的测试目标中,它们不存在于主包中,因此当我从主包中按其名称加载 nib 时,我的应用程序崩溃了。我要么需要找到包含我的 nib 文件的正确包,要么需要使用路径加载 nib。

有没有人有任何一个解决方案?[NSBundle bundleForClass:[self class]]不起作用。我认为笔尖和类文件不在同一个包中

4

1 回答 1

1

枚举捆绑包可能会有所帮助

for (NSBundle *bundle in [NSBundle allBundles])
{
    // can look for resources in bundle
    locatedPath = [bundle pathForResource:resourcePath ofType:type];

    // or maybe trying and load the nib from it?
    UINib *nib = [UINib nibWithName:@"Blah" bundle:bundle];

    // check for !nil ...
}
于 2011-11-04T03:14:39.890 回答