UITabBarController with diffent storyboard file for each ViewController of the TabBar

别来无恙 提交于 2020-01-03 17:35:13

问题


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

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