Uitabbar+nav of the common template framework for iOS projects

Source: Internet
Author: User

 在实际的项目开发中总是有几个比较常见的模板,小编这几天给大伙出几期常用模板的博客,希望大家多提宝贵的意见!  这几个月最常用的莫过于Nav+UITabBar模板了;在实际的项目中,我比较侧重于纯代码,比较不喜欢拖控件,至于利弊在这里不多说了,言归正传。

First create a blank scene in APPDELEGATE.M:
Self.window=[[uiwindow Alloc]initwithframe:[[uiscreen Mainscreen]bounds]];
Initialize Uitabbarcontroller
Self.tabbarcontroller=[[uitabbarcontroller Alloc]init];
To create a two view controller:
Firstviewcontroller *one=[[firstviewcontroller Alloc]init];
Secondviewcontroller *second=[[secondviewcontroller Alloc]init];
Create two navigation controllers and have the two navigation controllers control the respective view controllers:
Uinavigationcontroller *navfirst=[[uinavigationcontroller Alloc]initwithrootviewcontroller:one];
Uinavigationcontroller *navsecond=[[uinavigationcontroller Alloc]initwithrootviewcontroller:second];
Let Tabbarcontroller include these two navigation controllers:
[Self.tabbarcontroller Addchildviewcontroller:navfirst];
[Self.tabbarcontroller Addchildviewcontroller:navsecond];
Tailor the individual view controllers to:
[Email protected] "contact";
One.tabbaritem=[[uitabbaritem alloc]initwithtitle:@ "One" Image:[uiimage imagenamed:@ ""]
Selectedimage:nil];
[Email protected] "collection";
Second.tabbaritem=[[uitabbaritem alloc]initwithtitle:@ "Second" Image:nil Selectedimage:nil];
The main view on the set blank scene is: Tabbarcontroller:
[Self.tabbarcontroller Addchildviewcontroller:navsecond];
Modify the scene to be red:
Self.window.backgroundcolor=[uicolor Redcolor];
Show Scene:
[Self.window makekeyandvisible];
Create a Level two page in Firstviewcontroller
To create a navigation bar:
Uibarbuttonitem *rightbutton=[[uibarbuttonitem Alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemsearch Target:self Action: @selector (selectrightaction:)];
To implement a jump method:
-(void) Selectrightaction: (ID) sender
{
Backviewcontroller *backbutton;

backButton=[[BackViewController alloc]initWithNibName:@"BackViewController" bundle:nil];backButton.[email protected]"第二视图层";[self.navigationController pushViewController:backButton animated:NO];

}

code example: http://download.csdn.net/detail/it_ds/8568545

Uitabbar+nav of the common template framework for iOS projects

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.