The Uinavigationcontroller of Ios:ui series

Source: Internet
Author: User

  Again to the summary of the time, suddenly feel the time has been good fast ah, total sleep time is not enough, but this also no way ah, only their own time, although it is 0 basis, but this does not represent what, as long as the effort, the harvest is still some, at the same time I also believe that the vast number of Bo friends must have the same

Then let me explain what we are learning today, hehe. First in the beginning of the class, we did a short exercise, the knowledge of the past has a further understanding, but also improve the proficiency, but the time is always very fast, we immediately ushered in the new content we learn today uinavigationcontrol!

  First of all, let me introduce the next Uinavigationcontrol method of creation:

1. Create the navigation controller and specify the Rootviewcontroller of the navigation controller

2. Set the navigation controller to Rootviewcontroller

The specific creation process I will use the code to tell you, as follows:

Firstviewcontroller *FIRSTVC =[[Firstviewcontroller alloc] init]; NSLog (@"first page initialization complete"); Uinavigationcontroller*NAVC =[[Uinavigationcontroller alloc] INITWITHROOTVIEWCONTROLLER:FIRSTVC];    [FIRSTVC release]; NSLog (@"set the first page as the rootviewcontroller of the navigation controller"); //Step 2: Set the Rootviewcontroller of the Navigation controller to windowSelf.window.rootViewController =NAVC; NSLog (@"set the Rootviewcontroller of the Navigation controller to window"); [NAVC release];

Uinavigationcontrol, when the row controller, inherits from the view controller of the Uiviewcontroller, the view controller, is used to manage the Erie View Controller, the managed view controller is stored in the form of a stack (advanced post-out, LIFO)

Each navigation controller comes with a Navigationbar (navigation bar), Uinavigationbar inherits from UIView, Navigationbar is used to manage the display of the navigation bar (IOS7 is opaque before it becomes transparent)

At the same time, we can also set the navigation bar and the above things, the method is as follows:

// sets whether the navigation bar is translucent, sets the background color, and translucent is invalidated    NaviVC.navigationBar.translucent = YES;     // Set the color    of item on the navigation bar NaviVC.navigationBar.tintColor = [Uicolor purplecolor];         // set the navigation bar style    NaviVC.navigationBar.barStyle = Uibarstyleblack;

And then we went into this lesson the most important thing is that the value of the problem, in the method we learn today by the value of the property and the single-pass value.

The method for creating a single-pass value is:

1. Class methods

2. The return value type is the current class

3. Method Name: Default + class name

Let's take today's example:

The following illustration shows 1 2 3 steps

- (void) viewdidload{[Super Viewdidload]; Self.view.backgroundColor=[Uicolor Purplecolor]; //Do any additional setup after loading the view.Self.navigationItem.title =@"Home Page"; UILabel*label = [[UILabel alloc] Initwithframe:cgrectmake ( -, -, -, -)]; Label.text=@"User name"; Label.textalignment=Nstextalignmentright;    [Self.view Addsubview:label];        [Label release]; UILabel*label1 = [[UILabel alloc] Initwithframe:cgrectmake ( -, Max, -, -)]; Label1.Text=@"Sex"; Label1.textalignment=Nstextalignmentright;    [Self.view Addsubview:label1];        [Label1 release]; Field= [[Uitextfield alloc] Initwithframe:cgrectmake ( -, -, $, -)]; Field.borderstyle=Uitextborderstyleroundedrect; Field.placeholder=@"Please enter user name"; Field.autocorrectiontype=Uitextautocorrectiontypeno; Field.spellcheckingtype=Uitextspellcheckingtypeno;    [Self.view Addsubview:field];        [Field release]; Field1= [[Uitextfield alloc] Initwithframe:cgrectmake ( -, Max, $, -)]; Field1.borderstyle=Uitextborderstyleroundedrect; Field1.placeholder=@"Please enter gender";    [Self.view Addsubview:field1];        [Field1 release]; UIButton*button =[UIButton Buttonwithtype:uibuttontypesystem]; Button.frame= CGRectMake ( -, $, -, -);    [Button addtarget:self action: @selector (changpage:) forcontrolevents:uicontroleventtouchupinside]; [Button Settitle:@"Login"Forstate:uicontrolstatenormal];        [Self.view Addsubview:button]; UIButton*button1 =[UIButton Buttonwithtype:uibuttontypesystem]; Button1.frame= CGRectMake ( the, $, -, -);    [Button1 addtarget:self Action: @selector (changpage:) forcontrolevents:uicontroleventtouchupinside]; [Button1 Settitle:@"Cancel"Forstate:uicontrolstatenormal];        [Self.view Addsubview:button1]; UITapGestureRecognizer*tap =[[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (Returnthekeyborld:)];    [Self.view Addgesturerecognizer:tap];        [Tap release]; //Create a single case//Single *single = [single defaultsingle];//NSLog (@ "%@", single);//Single *single1 = [single defaultsingle];//NSLog (@ "%@", single1);//Single *single2 = [single defaultsingle];//NSLog (@ "%@", single2);}- (void) Returnthekeyborld: (UITapGestureRecognizer *) tap{ for(UIView *viewinchself.view.subviews) {if([Viewclass] = = [Uitextfieldclass]) {[View Resignfirstresponder]; }    }}- (void) didreceivememorywarning{[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}- (void) Changpage: (UIButton *) button{ Single*single =[single defaultsingle]; Single.namestring=Field.text; NSLog (@"%@", single.namestring); Homedetailviewcontroller*detail =[[Homedetailviewcontroller alloc] init]; Detail.namestring= [NSString stringWithFormat:@"Welcome%@ Sex%@ Landing Success", Field.text, Field1.text];    [Self.navigationcontroller Pushviewcontroller:detail Animated:yes]; [Detail release];
}
- (void) viewdidload{Self.view.backgroundColor=[Uicolor Redcolor];    [Super Viewdidload]; //Do any additional setup after loading the view.Self.navigationItem.title =@"Details Page"; UILabel*label = [[UILabel alloc] Initwithframe:cgrectmake ( -,0, $, -)]; Label.numberoflines=0; Label.center=Self.view.center;//label.text = _namestring;Single *single =[single defaultsingle]; Label.text=single.namestring; Label.textalignment=Nstextalignmentcenter;    [Self.view Addsubview:label]; [Label release];}
#import <Foundation/Foundation.h>@interface Single:nsobject@property (nonatomic, retain) nsstring*namestring, *genderstring;//How to create a single case//1. Class Methods//2. The return value type is the current class//3. Method Name: Default + class name+ (Single *) Defaultsingle; #import"Single.h"@implementation Single+ (Single *) defaultsingle{StaticSingle *single =Nil; if(single =Nil) { Single=[[Single alloc] init]; }    returnSingle ;}- (void) dealloc{self.namestring=Nil; Self.genderstring=Nil; [Super Dealloc];}

As shown below:

  Well, today's summary is here, not for others only for a little progress every day, we work together ha, round our common it dream!

The Uinavigationcontroller of Ios:ui series

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.