It’s quite possible, and a smart move - advertising your storyboards is cleaner interface files for scrolling, reducing loading time in Xcode and improving group editing.
I combed Qaru for a while and noticed that everyone was resorting to Custom Segues program settings or creating tab-based instances. Clap. I hacked into a simple subclass of UIViewController that you can use as a placeholder for your storyboards.
The code:
Header file:
Implementation File:
#import "TVStoryboardViewController.h" @interface TVStoryboardViewController() @property (nonatomic, strong) UIViewController *storyboardViewController; @end @implementation TVStoryboardViewController - (Class)class { return [self.storyboardViewController class]; } - (UIViewController *)storyboardViewController { if(_storyboardViewController == nil) { UIStoryboard *storyboard = nil; NSString *identifier = self.restorationIdentifier; if(identifier) { @try { storyboard = [UIStoryboard storyboardWithName:identifier bundle:nil]; } @catch (NSException *exception) { NSLog(@"Exception (%@): Unable to load the Storyboard titled '%@'.", exception, identifier); } } _storyboardViewController = [storyboard instantiateInitialViewController]; } return _storyboardViewController; } - (UINavigationItem *)navigationItem { return self.storyboardViewController.navigationItem ?: [super navigationItem]; } - (void)loadView { [super loadView]; if(self.storyboardViewController && self.navigationController) { NSInteger index = [self.navigationController.viewControllers indexOfObject:self]; if(index != NSNotFound) { NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers]; [viewControllers replaceObjectAtIndex:index withObject:self.storyboardViewController]; [self.navigationController setViewControllers:viewControllers animated:NO]; } } } - (UIView *)view { return self.storyboardViewController.view; } @end
Description:
- The view controller uses its Recovery ID to create storyboards in your project.
- After loading, it will try to replace itself with its UINavigationController viewController array with the layout of the initial view controller.
- Upon request, this subclass returns the UINavigationItem of the Storyboard's initial view controller. This is necessary so that the navigation elements loaded in the UINavigationBars correspond to the view controllers after the exchange.
Application:
To use it, assign it as a subclass of UIViewController in your storyboard owned by UINavigationController.

Give it a recovery identifier, and you're good to go.

Setup:
And here is how you set it up in the Storyboard:

This setting shows the tab bar controller with the navigation controllers as its first tab controllers. Each navigation controller has a simple UIViewController as its root view controller (I added UIImageViews to placeholders to make it easy to remember what it's attached to). Each of them is a subclass of TVStoryboardViewController. Each of them has a recovery identifier set for the storyboard to which they must refer.
Some win here:
- It seems to be best suited for modal presentations, where the subclass is the root view controller of the navigation controller.
- The subclass does not push any controllers on the stack - it swaps. This means that you don’t need to manually hide the back button or redefine the tab elsewhere.
- If you double-tap the tab, it will bring you back to the original type of storyboard, as expected (you will no longer see this placeholder).
- Super easy to configure - no user settings or setting multiple subclasses.
- You can add UIImageViews and whatever you like to widget controllers to make your storyboards more readable - they will never be shown.
Some limitations:
- This subclass must belong to the UINavigationController somewhere in the chain.
- This subclass will instantiate the source view controller in the storyboard. If you want to create an instance of the view controller down the chain, you can always split your storyboards and reapply this subclass trick.
- This approach does not work when you click on view controllers.
- This approach does not work when used as a built-in view controller.
- Messaging through segues probably won't work. This approach approaches settings where interface sections are unique, unrelated sections (presented both in models and through the tab bar).
This approach has been hacked to solve this UITabBarController problem, so use it as a partial solution to a larger problem. Hopefully Apple will improve in supporting multiple storyboards. However, to configure the UITabBarController, this should work.
Thomas verbeek
source share