我正在 iOS 中创建一个静态库。我在其中使用 Storyboard文件。为此,我创建了一个名为“OfferWallResources.bundle”的资源包文件,在其中添加了名为“Offerwall.storyboard”的 Storyboard文件。我正在尝试使用以下代码访问静态库中的 Storyboard :
NSBundle *bundle = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"OfferWallResources.bundle"];
UIStoryboard *s=[UIStoryboard storyboardWithName:@"Offerwall" bundle:bundle];
但我的应用程序因以下错误而崩溃:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Offerwall' in bundle NSBundle (loaded)'
我还尝试使用相同的代码访问目标项目中的相同 Storyboard 文件并且它有效。但是,我想在图书馆内访问它。我不明白我要去哪里错了。
最佳答案
我认为您没有正确实例化捆绑包。试试 [NSBundle bundleWithPath:]
或 [NSBundle bundleWithURL:]
.
关于ios - 无法访问 iOS 静态库中资源包文件中的 Storyboard ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35151174/