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