我是一名新的iOS開發人員。我必須開發一個靜態庫。我有很多視圖控制器,它們之間的流程是使用故事板來定義的。我從我的項目中創建了兩個目標。一個是靜態庫,另一個是捆綁。我用我的包裹來包含我的故事板。我已經使用這段代碼從storybaord啓動我的第一個viewcontroller。使用故事板在iOS中開發靜態庫
-(void)showFromViewController:(UIViewController *)vc{
NSBundle * bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"storyBoards" withExtension:@"bundle"]];
UIStoryboard * libStoryBoard = [UIStoryboard storyboardWithName:@"Main1" bundle:bundle];
ViewController1 * viewController = [libStoryBoard instantiateViewControllerWithIdentifier:@"ViewController1"];
[vc presentViewController:viewController animated:YES completion:NULL];
}
vc是調用此函數的ViewController。
是的,ViewController具有靜態庫的目標成員資格。
但包括「一個」,而在另一個項目「.bundle」,並呼籲上述功能之後,它拋出在控制檯登錄錯誤。
Unknown class ViewController1 in Interface Builder file.
任何人都可以建議使用故事板的靜態庫一起meright方式。如果是,那麼你能否指出從靜態庫中包含類的故事板啓動第一個視圖控制器的正確方法。
你確定你正在得到正確的包嗎? '[NSBundle bundleForClass:[ViewController1 class]]' – nhgrif
是的,我想。因爲如果我直接在靜態庫中使用storybaord並參考電子郵件包中的故事板,它仍會拋出相同的錯誤。 – hcnimkar
它不會在主要包中。 – nhgrif