Using a single storyboard makes the project difficult and manageable, and using pure code can be cumbersome, so if you combine the two and use multiple storyboard, it makes the project simple and convenient.
The following is an example of a simple view relationship that describes the use of multiple storyboard.
① have Page1 and page2 two pages, click on the detail button Page1 will pop up page1detail view, click the Page1detail return button will return.
②page1 and Page2 switch through Tabbar.
We create Page1, Page2, Page1detail three storyboard, each with its own controller, note that each controller is initial viewcontroller, otherwise it crashes when the storyboard controller is loaded .
"Concrete Steps"
① Delete the default settings for main interface in the project settings, because to connect two controllers with Tabbar, it should be implemented by code.
② creates a window in Appdelegate, creates a tabbar, and sets the rootviewcontroller of the window to Tabbar.
Load storyboard, get the default controller from storyboard, then set Tabbar viewcontrollers to Page1, Page2, and finally don't forget to call the Makekeyandvisible Method of window.
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions { Self.window = [[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds]; Self.window.backgroundColor = [Uicolor whitecolor]; Uitabbarcontroller *TB = [[Uitabbarcontroller alloc] init]; Load Storyboard Uistoryboard *PAGE1SB = [Uistoryboard storyboardwithname:@ "Page1" bundle:nil]; Uistoryboard *PAGE2SB = [Uistoryboard storyboardwithname:@ "Page2" bundle:nil]; Created and added to Tabbar tb.viewcontrollers = @[page1sb.instantiateinitialviewcontroller, Page2sb.instantiateinitialviewcontroller]; Self.window.rootViewController = TB; [Self.window makekeyandvisible]; return YES;}
By this setting, the Tabbar can be implemented with a Page1, Page2 two controllers.
③ modal a detail controller when clicking the Detail button in Page1, the same is done by loading storyboard, getting the default controller, calling Presentviewcontroller::: Method modal this controller.
-(Ibaction) Detailclick: (ID) Sender { //load Storyboard uistoryboard *detailsb = [Uistoryboard storyboardwithname:@ "Page1detail" bundle:nil]; Create Controller Uiviewcontroller *VC = Detailsb.instantiateinitialviewcontroller; [Self PRESENTVIEWCONTROLLER:VC animated:yes completion:nil]; }
The return of the ④modal controller is implemented through dismiss.
-(Ibaction) Backclick: (ID) Sender { [self dismissviewcontrolleranimated:yes completion:nil]; }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
(90) Separate management of the controller using multiple storyboard+ codes