Eugene
Eugene

Reputation: 10045

UIStoryboard+UITabBarController+Separate storyboards

There's a main UIStoryboard with a UITabBarController that has 5 items each of which is big enough to be represented by its own storyboard instance. I would like to divide all 5 into different storyboards. In other words, when TabBarItem1 is selected, I would like to load its respective UIViewController from a different storyboard, is it possible to achieve this? I'm thinking about creating the UITabBarController programmatically for this, would that be the most graceful solution?

EDIT --

  NSMutableArray *viewControllers = [NSMutableArray array];

  MyViewController1 *myController1 = [[StoryboardManager myStoryboard1] instantiateInitialViewController];
  myController1.title = @"Title";
  [viewControllers addObject:myController1];

  MyViewController2 *myController2 = [[StoryboardManager myStoryboard2] instantiateInitialViewController];
  myController2.title = @"Title";
  [viewControllers addObject:myController2];
  // ...etc
  self.viewControllers = viewControllers; // self - subclass of a UITabBarController

Upvotes: 1

Views: 786

Answers (2)

George
George

Reputation: 756

If you work with iOS9, it's possible to select all view controllers in one tab of UITabbarController, select Editor -> Refactor to Storyboard in XCode, and create a new Storyboard. XCode will do everything else automatically. Unfortunately, it works only from iOS 9.

Upvotes: 0

rdelmar
rdelmar

Reputation: 104082

You should be able to do this in code, by getting an instance of the other storyboards, instantiating their initial view controller, and finally, adding those to the tab bar controllers viewControllers array.

Upvotes: 2

Related Questions