问题
My team is developing an application that has a UITabBarController. We are using Storyboard to develop the interfaces and the flows.
Since we are a team, we cannot put all flow in just one storyboard, because it will cause in problems with syncing with SVN. So, the solution is to put each tab`s flow in one different storyboard file.
The connection between storyboards is not the problem when I can create an object to do the connection (a button, for example) as we can see in this tutorial.
But when I put a UITabBarController in one storyboard, I cannot manage the view element of the bottom bar (the tabBar itself) in a way to programmatically set the storyboard that will be displayed for each button of the tabBar.
For now, I have the TabBar and the UIViewControllers in the same .storyboard file as we can see:
So what I need is to connect different storyboards through one UITabBarController. How to do that?
回答1:
You're kind of missing out on the point of storyboards, which is to let you see the structure of the app and relationships between view controllers.
It sounds like you're not getting a lot of benefit from using a storyboard for the tab bar controller, so it might make sense to set that up programmatically, which lets you instantiate each of the view controllers yourself using separate storyboards.
Alternatively, you could include the tab bar controller, any necessary navigation controllers, and the root controller for each nav controller in one storyboard, and then have each of those root controllers load subsequent view controllers from other storyboards.
回答2:
You can use Storyboard references to keep the sections of your app separate and in individual Storyboard files. With UITabBarController just ctrl-link to the reference and make sure that you add a UITabBarItem to your ViewController in the new Storyboard.
回答3:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Yourstoryboard" bundle:nil];
UINavigationController *thisController = [storyboard instantiateViewControllerWithIdentifier:@"YourID"];
mytabBarController.viewControllers = @[phoneViewController];
I still think you should use git : )
来源:https://stackoverflow.com/questions/17924064/uitabbarcontroller-with-diffent-storyboard-file-for-each-viewcontroller-of-the-t