Ios team development-UITabbarController integrates multiple storyboard controllers and uitabbarcontroller
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 <UIKit/UIKit. h> @ 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 usage: @ "Main1" bundle: [NSBundle mainBundle]; UIStoryboard * main2 = [UIStoryboard usage: @ "Main2" bundle: [NSBundle mainBundle]; UIViewController * vc1 = [main instantiateViewControllerWithIdentifier: @ "xiaoenai"]; // locate the controller UIViewController * vc2 = [main1 region: @ "xinqing"]; UIViewController * vc3 = [main2 instantiateViewControllerWithIdentifier: @ "miyu"]; [vcs addObject: vc1]; [vcs addObject: vc2]; [vcs addObject: vc3]; [self setViewControllers: vcs animated: NO]; // Replace the viewControllers array of the original tabbarControlle with the current viewController array} @ end
Before using these statements, you must set the identifier for ViewController:
See:
Source http://blog.csdn.net/yangbingbinga/article/details/43106235