In a tabbarcontroller, how do you integrate controller pages from multiple storyboard?
Why is there more than one storyboard? In a project developed by many people, depending on the functional business module, multiple storyboard can be used, each storyboard complete the controller or other view of its own module: After the last finish, You only need to find the corresponding storyboard, and then find the controllers you need in the storyboard:
So how do you integrate 3/or more storyboard controllers pages onto a Tabbar?
Directly on the code, slowly explain:
1. First 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 HT Tp://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 hold the Controller object Uistoryboard *main=[uistoryboard s toryboardwithname:@ "Main" Bundle:[nsbundle mainbundle]];/first find the corresponding storyboard Uistoryboard *main1=[uistoryboard storyboardwithname:@ "Main1" Bundle:[nsbundle Mainbundle]; Uistoryboard *main2=[uistoryboard storyboardwithname:@ "Main2" Bundle:[nsbundle Mainbundle]; Uiviewcontroller *vc1=[main instantiateviewcontrollerwithidentifier:@ "Xiaoenai"];// Locate the controller Uiviewcontroller *vc2=[main1 instantiateviewcontrollerwithidentifier:@ According to the StoreID of the storyboard and controller. Xinqing "]; Uiviewcontroller *vc3=[main2 instantiateviewcontrollerwithidentifier:@ "Miyu "]; [VCs ADDOBJECT:VC1]; [VCs ADDOBJECT:VC2]; [VCs ADDOBJECT:VC3]; [Self Setviewcontrollers:vcs animated:no];//replaces the viewcontrollers array of the original Tabbarcontrolle with the current Viewcontroller array} @end
Of course, before using these statements, you need to set an identifier for Viewcontroller:
See:
Original source http://blog.csdn.net/yangbingbinga/article/details/43106235
iOS team Development-uitabbarcontroller integrates multiple storyboard controllers