我想为我的 iOS 应用程序中的每个 UIViewcontroller 提供单独的 Storyboard文件。
那么我们如何为每个 Controller 分配不同的 Storyboard呢?另外,我们如何在它们之间进行导航?
我这样做是为了避免 svn 冲突,而很多人都在处理 UI。
最佳答案
获取对 Storyboard的引用...
UIStoryboard *someStoryboard = [UIStoryboard storyboardWithName:@"NameOfYourStoryboard" bundle:nil];
然后从该 Storyboard中实例化初始 View Controller ...
UIViewController *initialViewController = [someStoryboard instantiateInitialViewController];
或由 Storyboard标识符标识的其他一些 View Controller ...
UIViewController *someOtherViewControllerFromTheStoryboard = [someStoryboard instantiateViewControllerWithIdentifier:@"SomeViewControllersStoryboardIdentifier"];
之后您可以简单地推送(在导航 Controller 内)或显示新的 View Controller 。
从 iOS 9.0 开始,您甚至可以通过 Storyboard本身中的 Storyboard引用来连接 Storyboard: https://developer.apple.com/library/prerelease/ios/recipes/xcode_help-IB_storyboard/Chapters/AddSBReference.html
关于ios - 在 iOS App 中的多个 Storyboard之间导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33731486/