ios - 无法访问 iOS 静态库中资源包文件中的 Storyboard

标签 ios objective-c iphone xcode static

我正在 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/

相关文章:

iphone - 如何在应用程序中检测免打扰模式?

ios - Cocos2d-x如何创建带有标题和字体的图片按钮

ios - 字体在UILabel中无法正确显示-裁剪了Ascender或Descender

iphone - NSManagedObject 中的可变集?

objective-c - 将 int64_t 转换为 NSInteger

javascript - 使用 cocoa 将 JavaScript 注入(inject)网站时遇到问题

iphone - 我正在学习的 "Objective-C"有多少是通用的 Objective-C,而不是 Apple 的框架?

iphone - 针规的 UIControl 又名 Google O Meter

ios - 对 NSDictionary 的 NSArray 进行排序

ios - 根据一个对象中的一个值根据一个值对 NSObject 数组进行排序