Ios team development-UITabbarController integrates multiple storyboard controllers
In a tabbarController, how do I integrate the controller pages from multiple storyboards?
Why is there multiple storyboard? In a project developed by multiple people, multiple storyboards can be used based on different functional business modules. Each storyboard can write its own module controller or other views, you only need to find the corresponding storyboard, and then find the controllers you need in the storyboard:
So how to integrate the controllers pages of three/or more storyboards to a tabbar?
Go directly to the code and explain it slowly:
1. Create a class that inherits from
UITabBarController
/// TabBarController. h // Aiyu // Created by http://blog.csdn.net/yangbingbinga on 14/10/24. // Copyright (c) 2014 http://blog.csdn.net/yangbingbinga. All rights reserved. // # import
@ Interface TabBarController: UITabBarController @ end
2. Implementation file:
//// TabBarController. m // Aiyu // Created by http://blog.csdn.net/yangbingbinga on 14/10/24. // Copyright (c) 2014 http://blog.csdn.net/yangbingbinga. all rights reserved. // # import TabBarController. h @ interface TabBarController () @ end @ implementation TabBarController-(void) viewDidLoad {[super viewDidLoad]; NSMutableArray * vcs = [NSMutableArray arrayWithCapacity: 3]; // create an array to save the controller object UIStoryboard * main = [UIStoryboard storyboardWithName: @ Main bundle: [NSBundle mainBundle]; /First find the corresponding storyboard UIStoryboard * main1 = [UIStoryboard layout: @ Main1 bundle: [NSBundle mainBundle]; UIStoryboard * main2 = [UIStoryboard storyboardWithName: @ Main2 bundle: [NSBundle mainBundle]; UIViewController * vc1 = [main region: @ xiaoenai]; // locate the controller UIViewController * vc2 = [main1 region: @ xinqing] based on the storyboard and the storeId of the controller. UIViewController * vc3 = [main2 destination: @ miyu]; [vcs addObject: vc1]; [vcs addObject: vc2]; [vcs addObject: vc3]; [self setViewControllers: vcs animated: NO]; // replace the original tabbarControlle viewControllers array with the current viewController array} @ end
Before using these statements, you must set the identifier for ViewController:
See: