1.UINavigationCotroller
The 1> uinavigationcontoller is stored in the stack area.
The order of the 2> stack area is advanced and post-out.
3>uinavigationcontroller not a sub-controller is pressed into the stack, and then through the method to eject the top controller.
3> jumps to the next controller by Pust method.
4> can be returned to the previous controller via the Pop method
2. Create a Uinavigationcontroller
// 2. Create a controller Uinavigationcontroller *nav = [[Uinavigationcontroller alloc]init]; ///2.1 Press the first controller into the stack hmoneviewcontroller *ONEVC = [[Hmoneviewcontroller alloc]init]; [Nav PUSHVIEWCONTROLLER:ONEVC Animated:yes]; ///2.2 Set window root controller Self.window.rootViewController = nav ; // 2.3 Let window be the main window and visible [Self.window makekeyandvisible];
3. Switch the controller via the button
// button click event -(void) buttondidclick { // Create a second controller Hmtwoviewcont Roller *TWOVC = [[Hmtwoviewcontroller alloc]init]; // Push the second controller into the stack [Self.navigationcontroller PUSHVIEWCONTROLLER:TWOVC animated:yes]; }
4. Setting Uinavigationcontroller navigation through code
//4.1 Setting the title of the controllerSelf.navigtionItem.title =@"Red Controller"; //4.1.1 The above code can be abbreviatedSELF.TITLR =@"Red Controller"; //4.1.2 Setting the caption of a custom oneSelf.navigationItem.titleView = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"Maintitle"]]//4.2 Set the color of the navigation bar, to get the appearance of Navigationbar to set[[Uinavigationbar appearance] Setbartintcolor:[uicolor Bluecolor]]; //4.3 Setting the color of the title of Navigationbar[[Uinavigationbar appearance]settitletextattributes:@{Nsforegroundcoloratt Ributename:[uicolor Whitecolor]}]; //4.4 Set Left button right button//4.4.1 Creating a custom buttonSelf.navigationItem.leftBarButtonItem =[[Uibarbuttonitem alloc] Initwithcustomview:button]//4.4.2 Create a text buttonSelf.navigationItem.rightBarButtonItem = [[Uibarbuttonitem alloc] Initwithtitle:@"Next Controller"style:uibarbuttonitemstyleplain Target:nil Action:nil]; //4.4.3UIBarButtonItme System-provided type creation methodUibarbuttonitem *item = [[Uibarbuttonitem alloc] initwithbarbuttonsystemitem:< button type > target:< who executes the method > action:< Methods of execution >]//4.5 Set Back button, pass a custom button, the system will automatically help us to add "<"Self.navigationItem.backBarButtonItem = [[Uibarbuttonitem alloc] Initwithcustomview:button];
5. Create a controller from storyboard
1> setting the root controller for Uinavigationcontroller
The 2> switches the controller via a button, with push and modalbefore I OS8. after IOS8 with show and present Modally.
2.1.show animation is coming from the right.
2.2.present Modally animation is coming down from below
2.3.Custom is a custom jump and will be talked about later .
3> if out of the stack, can not be implemented using off-line method, you must use code, storyboard midline is not cross
// if out of the stack, can not be implemented using off-line method, you must use code, storyboard midline is not cross // let the controller out of the stack, return to the previous controller [Self.navigationcontroller popviewcontrolleranimated:yes]; // let the controller out of the stack and return to the controller. [Self.navigationcontroller poptorootviewcontrolleranimated:yes]; // let the controller out of the stack, return to the specified controller [Self.navigationcontroller poptoviewcontroller: Controller name Animated:yes]; // let the controller out of the stack, eject the top of the controller [Self.navigationcontroller Popoverpresentationcontroller];
6. Method to invoke when the view changes
//when the view is going to be displayed, it will be called- (void) Viewwillappear: (BOOL) Animated//when the view is finished, it is called- (void) Viewdidappear: (BOOL) Animated//when the graph is going to disappear, call- (void) Viewwilldisappear: (BOOL) Animated//call when the graph disappears- (void) Viewdiddisappear: (BOOL) Animated//called when the view load is complete- (void) Viewdidload
Introduction to the use of Uinavigationcontroller