iOS Foundation-uikit framework-Multi-controller management-uitabbarcontroller

Source: Internet
Author: User

Uitabbarcontroller

Simple use of Uitabbarcontroller

First, the creation of Uitabbarcontroller (using code)
1. Create a new empty project in MJAPPDELEGATE.M's didfinishlaunch ... Method in
1. Create a Tabbar controller
Uitabbarcontroller *TABBARVC = [[Uitabbarcontroller alloc] init];

2. The root controller set to window
Self.window.rootViewController = TABBARVC;

3. Adding a child controller
Uiviewcontroller *VC1 = [[Uiviewcontroller alloc] init];
Vc1.view.backgroundColor = [Uicolor Redcolor];
Vc1.tabBarItem.title = @ "Contact";
Vc1.tabBarItem.image = [UIImage imagenamed:@ "Tab_buddy_nor"];

Uiviewcontroller *VC2 = [[Uiviewcontroller alloc] init];
Vc2.view.backgroundColor = [Uicolor Bluecolor];
Vc2.tabBarItem.title = @ "dynamic";
Vc2.tabBarItem.image = [UIImage imagenamed:@ "Tab_qworld_nor"];

Uiviewcontroller *VC3 = [[Uiviewcontroller alloc] init];
Vc3.view.backgroundColor = [Uicolor Greencolor];
Vc3.tabBarItem.title = @ "Settings";
Vc3.tabBarItem.image = [UIImage imagenamed:@ "Tab_me_nor"];

Tabbarvc.viewcontrollers = @[vc1,vc2,vc3];


[Self.window makekeyandvisible];


PS: The selected state of the picture is automatically turned blue, do not do it yourself.


Uitabbarcontroller View structure (note that the height of the Tabbar is 49)
PS: When you click on the leftmost side, display VC1 view, click in the middle, first move the VC1 view (not destroyed), and then put the VC2 view, unless a memory warning occurs to destroy the currently unused view

Uitabbar

Uitabbarbutton


Ii. creation of Uitabbarcontroller (using storyboard)
1. Come to storyboard, remove the default controller view and drag a tabbarcontroller. Remove the two controller view that is connected to the line and remove the line. Drag 3 Viewcontroller.
2. Delete the default controller file, create a new 3 controller file, and modify the class corresponding to the 3 Viewcontroller in storyboard.
3. Come to storyboard, right-click Tabbarcontroller, and connect the view controllers sequentially to the newly-dragged Viewcontroller.
4. Select the 3 viewcontroller buttons separately and modify the title

iOS Foundation-uikit framework-Multi-controller management-uitabbarcontroller

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.