Ios team development-UITabbarController integrates multiple storyboard controllers

Source: Internet
Author: User

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:

 




 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.