Ios team development-UITabbarController integrates multiple storyboard controllers and uitabbarcontroller

Source: Internet
Author: User

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





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.