IOS中用UIStoryBoard类初始化/跳转控制器
1.空project中通过创建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];