In the previous article, add Uibarbuttonitem, then say the interface switch;
1, first we add a button in the Rootviewcontroller just now to implement the jump:
Open rootviewcontroller.m (I'll keep writing) and add a jump button:
:
2, button action realization, a new newviewcontroller inherit from Uiviewcontroller; Pushviewcontroller to Navigationcontroller;
#import " NewViewController.h "
-(void) nextaction{ *NEWVC = [[Newviewcontroller alloc] init]; [Self.navigationcontroller PUSHVIEWCONTROLLER:NEWVC Animated:yes]; @" Newviewcontroller " ;}
Click Button,back to bring the system to its own button;
If you do not want to use the system's own button, we can customize the button:
Uibarbuttonitem *backbutton = [[Uibarbuttonitem alloc] Initwithtitle:@ " back " Style:uibarbuttonitemstyledone Target:nil Action:nil]; = Backbutton;
3, the title of the custom:
1 #import "NewViewController.h"2 3 @interfaceNewviewcontroller ()4 5 @end6 7 @implementationNewviewcontroller8 9- (void) Viewdidload {Ten [Super Viewdidload]; One //Do any additional setup after loading the view. A -UILabel *title =[[UILabel alloc] init]; -Title.text =@"title"; theTitle.font = [Uifont systemfontofsize: -]; - [title SizeToFit]; -Self.navigationItem.titleView =title; - +}
:
4. If you want to place more than one button:
Nsarray *colorarray = @[@ " black "@ " white "@ " Gray " ]; *segmentctrl = [[Uisegmentedcontrol alloc] initwithitems:colorarray]; 1 ; = [Uicolor redcolor]; = Segmentctrl;
:
To add a click response event:
[Segmentctrl addtarget:self Action: @selector (segmentaction:) forcontrolevents:uicontroleventvaluechanged];
- (void) Segmentaction: (ID) segment{Switch([segment Selectedsegmentindex]) { Case 0: {Uialertview*alert = [[Uialertview alloc] Initwithtitle:@"Tips"Message@"you have selected the color black" Delegate: Self Cancelbuttontitle:@"is a"Otherbuttontitles:@"No", nil]; [Alert show]; } Break; Case 1: {Uialertview*alert = [[Uialertview alloc] Initwithtitle:@"Tips"Message@"you have selected the color white" Delegate: Self Cancelbuttontitle:@"is a"Otherbuttontitles:@"No", nil]; [Alert show]; } Break; Case 2: {Uialertview*alert = [[Uialertview alloc] Initwithtitle:@"Tips"Message@"you have selected a color gray" Delegate: Self Cancelbuttontitle:@"is a"Otherbuttontitles:@"No", nil]; [Alert show]; } Break; default: Break; }}
:
iOS Basics (11) Use of--uinavgationcontroller (ii) page switching