Move between multiple storyboards by replacing the windows root controller

心不动则不痛 提交于 2019-12-12 00:26:34

问题


To move between VCs on a single storyboard, I use the first custom segue from the post : bidirectional storyboard travel without stacking This replaces the window's root view controller with the destination view controller, so the VCs do not stack and cause memory allocation issues.

I need to use multiple storyboards and so I am after a method of moving to a second storyboard that replaces the windows root controller with the initial VC of the new storyboard (I.e in a similar way to the custom segue I have used throughout the rest of the project.)

The solution should ideally work for IOS6 & IOS7 (the pseudo-segue method has been updated to IOS7 only)

Any ideas?


回答1:


You can't do this with a segue. Segues can only be made between controllers in the same storyboard. The only way to do this, is in code by instantiating that first controller, and setting it as the window's root view controller.

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"SomeOtherStoryboard" bundle:nil];
NewController *new = [sb instantiateInitialViewController];
self.view.window.rootViewController = new;


来源:https://stackoverflow.com/questions/20309667/move-between-multiple-storyboards-by-replacing-the-windows-root-controller

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