1.空工程中通过创建storyboard文件加载页面
//获取Main.storyboard
UIStoryboard
*mainStory = [UIStoryboard
storyboardWithName:@"Main"
bundle:nil];
//获取Main.storyboard中的第2个视图
SecondViewController
*secondController = [mainStory
instantiateViewControllerWithIdentifier:@"SecondStory"];
//设置窗体的根视图为Storyboard里的视图
self.window.rootViewController
= secondController
StoryBoard的ID在这里设置:
2. 其他控制器中设置StoryBoard的初始控制器为window的根控制器
UIStoryboard *stotyb = [UIStoryboard storyboardWithName:@"Second" bundle:nil];
[self.view.window setRootViewController:stotyb.instantiateInitialViewController];
3.跳转到Storyboard中某个控制器
//获取Main.storyboard
UIStoryboard
*mainStory = [UIStoryboard
storyboardWithName:@"Main"
bundle:nil];
//获取Main.storyboard中的第2个视图
SecondViewController
*secondController = [mainStory
instantiateViewControllerWithIdentifier:@"SecondStory"];
//跳转页面
[self
presentViewController:secondController
animated:YES
completion:nil];