Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please more advice, if you feel good please support a lot of praise. Thank you! Hopy;)
If you want to develop a tab-type view of the app, you can use the corresponding template in Xcode
The template is naturally used storyboard that set of things, in order to better understand the xib layout, we do not need to storyboard template to create a Tabbar view of the app.
First step: Create a single View App
Open Xcode, select the single View app template, and create a new project. Then delete all the storyboard files in the project and delete the Viewcontroller class.
Step two: Clear the Start screen
Empty the section about the startup interface in your project:
You can also delete the corresponding 2 attributes in the Info.plist file, but it seems that you can not delete
Step three: Create a new Uiviewcontroller view
Select New Cocoa Touch class, select the new class named REDVC, inherit from Uiviewcontroller, and select Create Xib file. Open the Redvc.m file and add the following method:
-(ID) Initwithnibname: (NSString*) Nibnameornil Bundle: (NSBundle*) nibbundleornil{ Self= [SuperInitwithnibname:nibnameornil Bundle:nibbundleornil];if( Self) { Self. Title= @"Red";UIImage*image = [UIImageimagenamed:@"2.png"]; Cgimageref Imageref = Image. Cgimage; Self. Tabbaritem. Image= [[UIImageImagewithcgimage:imageref scale:2Orientation:uiimageorientationdown] Imagewithrenderingmode: Uiimagerenderingmodealwaysoriginal]; }return Self;}
Similarly, create 2 more classes, respectively, GREENVC and WHITEVC, as well as even corresponding to the above method, and make appropriate adjustments.
Fourth step: Modify the App startup method
Open the APPDELEGATE.M file and modify the method as follows:
- (BOOL) Application: (uiapplication*) Application Didfinishlaunchingwithoptions: (nsdictionary*) Launchoptions {//Override point for customization after application launch. Self. Window= [[UIWindowAlloc]initwithframe:[uiscreen Mainscreen]. Bounds];Uiviewcontroller*VC1 = [[Whitevc alloc]initwithnibname:@"WHITEVC"BundleNil];Uiviewcontroller*VC2 = [[REDVC alloc]initwithnibname:@"REDVC"BundleNil];Uiviewcontroller*VC3 = [[GREENVC alloc]initwithnibname:@"GREENVC"BundleNil]; _tabbarcontroller = [UitabbarcontrollerNEW]; _tabbarcontroller. Viewcontrollers= @[vc1,vc2,vc3]; [ Self. WindowSetrootviewcontroller:_tabbarcontroller]; [ Self. WindowMakekeyandvisible];return YES;}
Ok we basically finished, compile and run the app effect as follows:
Do not use storyboard in Xcode, create Tabbar mode view with pure Xib