Multiple entry points to a storyboard

好久不见. 提交于 2019-12-18 12:43:03

问题


I need to make a set of decisions in the AppDelegate on launch - depending on the outcome of those decisions I need to go to specific parts of the storyboard.

So my question is - WITHOUT using any nav or tab controllers, how do I go to a specific part of a storyboard?

OR

Is the only supported option having multiple storyboards - for each of the 'outcomes' and then loading those as required?

Thanks


回答1:


Give each of your ViewControllers a separate ID, and then instantiate the required one with:

UIViewController *initialVC = [storyboard instantiateViewControllerWithIdentifier:@"<identifier>"];



回答2:


Give each ViewController a unique identifier in the storyboard. Then in the appDelegate:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"PUT_UNIQUE_ID_HERE"];
    //DO WHAT YOU WANT WITH YOUR VIEWCONTROLLER
   //Example:Set it as the root view of the app window...


来源:https://stackoverflow.com/questions/8872215/multiple-entry-points-to-a-storyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!