XCODE6.1 using Tabbarcontroller control for switching programs

Source: Internet
Author: User

XCODE6.1 using Tabbarcontroller control for switching programs

The previous blog to create a new empty project from the beginning, and then create a new root controller, the paper uses the system's own Tabbarcontroller controller to achieve the view switch.

1. New Project

Create a new single Viewapplication project, and then delete the Xib file and the main interface as shown in.

Delete the test folder and delete the corresponding destination file. The default generated view controller Viewcontroller.h and. m files are also deleted.

2. Add a View Controller

Added two view controllers, new file selection Cocoatouch, and also create XIB file option selected

Complete the following as shown in:

3. Add a root View Controller

Add an export to the AppDelegate.h file;

@property (strong,nonatomic) Iboutlet Uitabbarcontroller *rootcontroller;

APPDELEGATE.C, modify the Didfinishlaunchingwithoptioins method code

  self window = [[ uiwindow Alloc initwithframe :[[ uiscreen Mainscreen bounds

    [[nsbundle mainbundle ] loadnibnamed : @ "Tabbarcontroller" Span style= "COLOR: #2E0D6E" >owner : self options : Nil ;

self. window . Rootviewcontroller = Self . Rootcontroller ;

self. window . BackgroundColor = [uicolorgreencolor];

[self. window makekeyandvisible ];

4. Create a Tabbarcontroller.xib file

The naming is consistent with the name referenced in the preceding code.

5. Add the tab Bar Controller control and set the association

Drag the tab Barcontroller control from the object library and enter the corresponding controller class in the identity Inspector. That is associated with the Rootcontroller export. Then set the association by dragging the small circle of the Rootcontroller output into the tab Bar Controller in the dock.

6. Customizing each View Controller

Set the nib name Aviewcontroller, and do not xib the extension.

Sets the class name in the identity detector.

After the setting is complete, the controller's name changes from Item1 to Itema, and the same way is set for the B view;

Run the test, you should be able to implement a click on the bottom of the control button to achieve the view switch, of course, there is no content in the view. In order to see clearly, you can add some controls in two views to differentiate them.

XCODE6.1 using Tabbarcontroller control for switching programs

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.