【发布时间】:2016-01-12 06:57:50
【问题描述】:
我是一名新的 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 具有静态库的目标成员资格。
但是,在另一个项目中包含“.a”和“.bundle”并调用上述函数后,它会在控制台日志中引发错误。
Unknown class ViewController1 in Interface Builder file.
任何人都可以建议使用故事板和静态库的正确方法。如果是,那么您能否指出从情节提要中启动第一个视图控制器的正确方法,该视图控制器的类包含在静态库中。
【问题讨论】:
-
你确定你得到了正确的捆绑包吗?
[NSBundle bundleForClass:[ViewController1 class]] -
是的,我想。因为如果我直接将故事板与静态库一起使用并从电子邮件包中引用故事板,它仍然会引发相同的错误。
-
它不会出现在主包中。
标签: ios objective-c uiviewcontroller storyboard