跨Storyboard调用

在开发中我们会有这种需求从一个故事板跳到另一个故事板

modal

1     UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@"Storyboard1" bundle:nil];//获取故事板
2     UIViewController *firstVC = [secondStoryboard instantiateViewControllerWithIdentifier:@"firstVC "];//获取故事板中的页面
3    [self presentViewController:firstVC animated:YES completion: nil];

push

1 UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@"Storyboard1" bundle:nil];
2 UIViewController *firstVC = [secondStoryboard instantiateViewControllerWithIdentifier:@"firstVC "];
3 [self.navigationController pushViewController:firstVC animated:NO];

注:获取故事板中的页面有两种方法

- (id)instantiateInitialViewController;//默认加载故事板中入口的页面

- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier;//按照指定ID找页面,可以加载故事板中任意的页面

posted @ 2015-07-06 17:21  zhangjing022  阅读(310)  评论(0编辑  收藏  举报