Uitabbarcontroller (tab bar Controller)

Source: Internet
Author: User

First, the basic concept of the tag bar controller

Uitabbarcontroller inherits from the view controller and manages the view controller in the form of a tab bar item, and the view controllers between the individual tab items are independent of each other and do not affect each other.

(1) The life cycle of each view controller in Uitabbarcontroller is consistent with the life cycle of Uitabbarcontroller;

(2) Click on different tab items (Uitabbaritem) to show the view of different views controller;

(3) The selected tab bar item corresponds to the view of the controller that is in the display state, and the other view controller's view is in the unloaded state.

Second, the advantages of the tag bar controller

(1) The application module, the low coupling between the modules, team Development Easy division of labor;

(2) The extension of the application is strong, can be selected according to the requirements of the increase, delete module.

Third, the creation of the tag bar control

Self.window =[[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds]; Self.window.backgroundColor=[Uicolor Whitecolor];    [Self.window makekeyandvisible]; Rootviewcontroller*rootctrl =[[Rootviewcontroller alloc] init]; //creating a navigation controllerUinavigationcontroller *navctrl =[[Uinavigationcontroller alloc] Initwithrootviewcontroller:rootctrl]; Navctrl.title=@"Home Page"; //Create a ViewUiviewcontroller *VC1 =[[Uiviewcontroller alloc] init]; Vc1.title=@"Collection"; Uiviewcontroller*VC2 =[[Uiviewcontroller alloc] init]; Vc2.title=@"Search"; Uiviewcontroller*VC3 =[[Uiviewcontroller alloc] init]; Vc3.title=@"Set"; Nsarray*controllers =[Nsarray Arraywithobjects:navctrl,vc1,vc2,vc3,nil]; //create an instance of a tab bar controllerUitabbarcontroller *tabctrl =[[Uitabbarcontroller alloc] init]; //assigns an array of view controller instances to TabctrlTabctrl.viewcontrollers =controllers; //2nd View tab (Index starting from 0) is selected by defaultTabctrl.selectedindex=1; //Add the Tabbarcontroller view as a child to the windowSelf.window.rootViewController = Tabctrl;

Uitabbarcontroller (tab bar Controller)

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.