Two icons in the title. When you click the icon, the page will jump to the next page (similar to the area near anjuke's new house)

Source: Internet
Author: User

 

When I first came in:

When you click the button on the right:

Rootviewcontroller. h

#import <UIKit/UIKit.h>@interface RootViewController : UIViewController{    UIButton * leftButton;    UIButton * rightButton;    UIViewController * firstController;    UIViewController * secondController;}@end

 

 

Rootviewcontroller. m

-(Void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view. // initialize the top button [self creatheadview]; // initialize the background image [self initbackview];} # pragma-mark-functions-(void) initbackview {firstcontroller = [[uiviewcontroller alloc] init]; firstcontroller. view. backgroundcolor = [uicolor redcolor]; [self. view addsubview: firstcontroller. view]; secondcontroller = [[uiviewcontroller alloc] init]; secondcontroller. view. backgroundcolor = [uicolor bluecolor];}-(void) creatheadview {uiview * headview = [[uiview alloc] initwithframe: cgrectmake (0, 0,100, 30)]; // The left button leftbutton = [uibutton buttonwithtype: uibuttontypecustom]; leftbutton. frame = cgrectmake (0, 0, 50, 30); leftbutton. tag= 201; leftbutton. enabled = no; [leftbutton setimage: [uiimage imagenamed: @ "Left"] forstate: uicontrolstatenormal]; [leftbutton addtarget: Self action: @ selector (doclickheadactions :) forcontrolevents: role]; [headview addsubview: leftbutton]; // the right button rightbutton = [uibutton buttonwithtype: uibuttontypecustom]; rightbutton. frame = cgrectmake (50, 0, 50, 30); rightbutton. tag = 301; [rightbutton setimage: [uiimage imagenamed: @ "right"] forstate: uicontrolstatenormal]; [rightbutton addtarget: Self action: @ selector (doclickheadactions :) forcontrolevents: role]; [headview addsubview: rightbutton]; self. navigationitem. titleview = headview;} # pragma-mark-doclickactions-(void) doclickheadactions :( uibutton *) BTN {If (BTN. tag = 201) {[secondcontroller dismissviewcontrolleranimated: no completion: Nil]; [BTN setimage: [uiimage imagenamed: @ "leftselect"] forstate: uicontrolstatenormal]; BTN. enabled = no; [rightbutton setimage: [uiimage imagenamed: @ "right"] forstate: uicontrolstatenormal]; rightbutton. enabled = yes;} else if (BTN. tag = 301) {[firstcontroller presentviewcontroller: secondcontroller animated: no completion: Nil]; [BTN setimage: [uiimage imagenamed: @ "rightselect"] forstate: uicontrolstatenormal]; BTN. enabled = no; [leftbutton setimage: [uiimage imagenamed: @ "Left"] forstate: uicontrolstatenormal]; leftbutton. enabled = yes ;}}

 

Two icons in the title. When you click the icon, the page will jump to the next page (similar to the area near anjuke's new house)

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.