4

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:

enter image description here

So what I need is to connect different storyboards through one UITabBarController. How to do that?

Renato Lochetti
  • 4,558
  • 3
  • 32
  • 49
  • First of all use bitbucket or git SVN for Xcode is like beer and wine for the stomach then just fix the conflicts for the storyboard. – Radu Jul 29 '13 at 12:33
  • We dont sync the files using xcode. We use other tools outside the xcode – Renato Lochetti Jul 29 '13 at 12:34
  • I know witch is really bad practice – Radu Jul 29 '13 at 12:35
  • Bitbucket is free and has private repositories and it has merge control and auto merge - it fixes the conflicts automatically or manually whit merge tools. Then you can use source tree -client for bitbucket. What you have is not a programing issue it's a version management issue – Radu Jul 29 '13 at 12:36
  • Nope. The project`s requirement is clear: we need to develop interfaces in a modular fashion. So we need to have different .storyboard files. – Renato Lochetti Jul 29 '13 at 12:40
  • It is not that easy, altough the storyboard is just an xml file, I found it really annoying to synchronize all incoming svn changes, especially with large storyboard. In some cases it was quicker to overwrite the local storyboard and visually recreate own pages and connection. – Leonardo Jul 29 '13 at 13:40

3 Answers3

5

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. enter image description here

Lee Probert
  • 10,308
  • 8
  • 43
  • 70
4
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Yourstoryboard" bundle:nil];

UINavigationController *thisController = [storyboard instantiateViewControllerWithIdentifier:@"YourID"];

mytabBarController.viewControllers = @[phoneViewController];

I still think you should use git : )

Radu
  • 3,434
  • 4
  • 27
  • 38
3

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.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • Thanks for the tip @Caleb. I agree with you. Can you help me with the code to set up the uitabbar programmatically and reference the connection with the ViewControllers in the others .storyboard files. I would greatly appreciate it. – Renato Lochetti Jul 29 '13 at 13:16
  • It's not hard, just create your view controllers and create a new tab bar controller using an array of the controllers. Check the docs. Post your code if you get stuck. – Caleb Jul 29 '13 at 13:22
  • These questions and their answers disagree with your first point @Caleb http://stackoverflow.com/questions/18710757/too-many-views-in-storyboard-xcode-running-slow http://stackoverflow.com/questions/20943892/using-multiple-storyboards-with-a-tabbarcontroller – Chucky Jul 05 '16 at 16:19
  • @Chucky I don't think they really disagree -- they only make the point that a single storyboard can become so large that it's unwieldy. It's undeniable that storyboards do, in fact, let you see the relationships between the view controllers that they contain. The Q's you link also don't seem like shining examples of app design -- for example, it's hard to imaging needing 20 *different* tables for settings unless you take a very naïve approach using static tables. – Caleb Jul 05 '16 at 17:40