使用故事板在iOS中开发静态库

使用故事板在iOS中开发静态库,ios,objective-c,uiviewcontroller,storyboard,Ios,Objective C,Uiviewcontroller,Storyboard,我是一个新的iOS开发者。我必须开发一个静态库。我有许多ViewController,它们之间的流是使用故事板定义的。我已经从我的项目中创建了两个目标。一个是静态库,另一个是bundle。我用我的包把我的故事板放在里面。我用这段代码从storybaord启动了我的第一个viewcontroller -(void)showFromViewController:(UIViewController *)vc{ NSBundle * bundle = [NSBundle bundleWithUR

我是一个新的iOS开发者。我必须开发一个静态库。我有许多ViewController,它们之间的流是使用故事板定义的。我已经从我的项目中创建了两个目标。一个是静态库,另一个是bundle。我用我的包把我的故事板放在里面。我用这段代码从storybaord启动了我的第一个viewcontroller

-(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”并调用上述函数后,它会在控制台日志中抛出一个错误

接口生成器文件中的未知类ViewController1。


有人能给我推荐一种使用故事板和静态库的正确方法吗。如果是,那么您能指出从故事板启动第一个viewcontroller的正确方法吗?静态库中包含了谁的类

LoginViewController *loginVC=[self.storyboard instantiateViewControllerWithIdentifier:@"loginView"];
[self presentViewController:loginVC animated:YES completion:nil];

我有一个类似的设置。我有我的主项目,我有一个ModelController子项目,它有一个静态库和一个资源包,在我的主项目中使用

我创建了一个故事板和一个测试视图控制器,并使用上面的方法加载

唯一可能让您注意到的是静态库>目标>构建阶段>复制标题>确保将ViewController1.h文件添加到此列表中


除此之外,一切对我都很好

我也做了同样的事情。由于我在不同的项目中使用了.a和故事板,我必须从捆绑包中检索故事板。我没有理解你所说的评论。NSURL*url=[[NSBundle mainBundle]URLForResource:@“index”with extension:@“html”子目录:@“websiteDir”];NSURLRequest*request=[nsurlRequestRequestWithURL:url];[self.webView加载请求:请求];你确定你买对了包裹吗<代码>[NSBundle bundleForClass:[ViewController1类]]我想是的。因为如果我直接在静态库中使用storybaord并引用电子邮件包中的故事板,它仍然会抛出相同的错误。它不会在主包中。你能说明这有什么关系吗。因为我试过这样做,但仍然得到同样的错误。我想错误是因为ViewController1.m没有加载到内存中。