故事板的多个入口点

iOS*_*Fun 2 iphone point storyboard ios

我需要在发布时在AppDelegate中做出一系列决策 - 取决于我需要转到故事板特定部分的决策结果.

所以我的问题是 - 没有使用任何导航或标签控制器,我如何去故事板的特定部分?

要么

是唯一支持多个故事板的选项 - 对于每个'结果',然后根据需要加载它们?

谢谢

Hub*_*yer 11

为每个ViewController提供故事板中的唯一标识符.然后在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...
Run Code Online (Sandbox Code Playgroud)


iku*_*dia 7

为每个ViewControllers分配一个单独的ID,然后使用以下命令实例化所需的ID:

UIViewController *initialVC = [storyboard instantiateViewControllerWithIdentifier:@"<identifier>"];
Run Code Online (Sandbox Code Playgroud)

  • 感谢您的回复...我实际上想出了我想要做的事情:在做出决定的app委托中,我得到了故事板,然后是你的例子中的视图控制器,然后我将self.window.rootviewcontroller设置为那个新的视图控制器.否则,如果它没有通过决策测试,那么我只是让它默认为主故事板.要从一个故事板移动到另一个故事板,我一直在使用带有完成处理程序的instantiateView,然后在那里删除该视图,从它的superview推送. (2认同)