![](/img/trans.png)
[英]Cannot instantiate viewcontroller present in the storyboard in resource bundle file inside iOS static library
[英]Cannot access storyboard in resource bundle file inside iOS static library
我在iOS中創建一個靜態庫。 我在其中使用情節提要文件。 為此,我創建了一個名為“ OfferWallResources.bundle”的資源包文件,在其中添加了名為“ Offerwall.storyboard”的情節提要文件。 我正在嘗試使用以下代碼訪問靜態庫中的情節提要:
NSBundle *bundle = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"OfferWallResources.bundle"];
UIStoryboard *s=[UIStoryboard storyboardWithName:@"Offerwall" bundle:bundle];
但是我的應用程序崩潰並出現以下錯誤:
由於未捕獲的異常“ NSInvalidArgumentException”而終止應用程序,原因:“在捆綁包NSBundle中已找到名為“ Offerwall”的故事板(已加載)”
我還嘗試使用相同的代碼訪問目標項目中的相同的故事板文件,並且該文件可以正常工作。 但是,我想在庫中訪問它。 我不明白我要去哪里錯了。
我認為您沒有正確實例化包。 嘗試使用[NSBundle bundleWithPath:]
或[NSBundle bundleWithURL:]
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.