Simple code sharing on the navigator on the first several pages of the Japanese music Map

Source: Internet
Author: User
// Appdalegate part
-(Bool) Application :( uiapplication *) Application didfinishlaunchingwitexceptions :( nsdictionary *) launchoptions {self. window = [[uiwindow alloc] initwithframe: [[uiscreen mainscreen] bounds]; // override point for customization after application launch. self. window. backgroundcolor = [uicolor whitecolor]; [self. window makekeyandvisible]; // set viewcontroller1 * viewctrl1 = [[viewcontroller1 alloc] init]; uinavigationcontroller * Navi = [[uinavigationcontroller alloc] handler: viewctrl1]; Navi. navigationbarhidden = yes; self. window. rootviewcontroller = Navi; return yes ;}

 

// Encapsulate button-(uibutton *) gzybutton :( nsstring *) image andframe :( cgrect) frame0 andaction :( SEL) action0 {uibutton * BTN = [uibutton buttonwithtype: uibuttontypecustom]; uiimage * image1 = [uiimage imagenamed: Image]; [BTN setimage: image1 forstate: uicontrolstatenormal]; [BTN addtarget: Self action: action0 forcontrolevents: uicontroleventtouchupinside]; BTN. frame = frame0; [self. view addsubview: BTN]; return BTN;} // encapsulate view-(uiimageview *) gzyview :( nsstring *) image0 andfram :( cgrect) FRAM {uiimageview * imageview = [[uiimageview alloc] initwithframe: fram]; uiimage * image = [uiimage imagenamed: image0]; [imageview setimage: Image]; [self. view addsubview: imageview]; return imageview;} // ------------------------------- gorgeous split line loading // load view-(void) LoadImage {[self gzyview: @ "main_bg" andfram: cgrectmake (0, 0,320,580)];} // Load button-(void) creatbtn {[self gzybutton: @ "main_study" andframe: cgrectmake (10,400, 93,163) andaction: @ selector (nextpage :)];} // function of the button-(void) nextpage :( uibutton *) sender {viewcontroller2 * viewctrl2 = [[viewcontroller2 alloc] init]; [self. navigationcontroller pushviewcontroller: viewctrl2 animated: Yes];}-(void) viewdidload {[Super viewdidload]; [self LoadImage]; [self creatbtn];}

Second viewcontroller

// Encapsulate button-(uibutton *) gzybutton :( nsstring *) image andframe :( cgrect) frame0 andaction :( SEL) action0 {uibutton * BTN = [uibutton buttonwithtype: uibuttontypecustom]; uiimage * image1 = [uiimage imagenamed: Image]; [BTN setimage: image1 forstate: uicontrolstatenormal]; [BTN addtarget: Self action: action0 forcontrolevents: uicontroleventtouchupinside]; BTN. frame = frame0; [self. view addsubview: BTN]; return BTN ;}// Encapsulate all Japanese buttons-(uibutton *) japannextfram :( cgrect) fram andaction :( SEL) action {uibutton * btn3 = [uibutton buttonwithtype: uibuttontypecustom]; btn3.frame = fram; // btn3.backgroundcolor = [uicolor clearcolor]; btn3.backgroundcolor = [uicolor clearcolor]; [btn3 addtarget: Self action: action forcontrolevents: uicontroleventtouchupinside]; [self. view addsubview: btn3]; return btn3;} // encapsulate view-(uiimageview *) gzy View :( nsstring *) image0 andfram :( cgrect) fram {uiimageview * imageview = [[uiimageview alloc] initwithframe: fram]; uiimage * image = [uiimage imagenamed: image0]; [imageview setimage: Image]; [self. view addsubview: imageview]; return imageview;} // Japanese letter button //-(void) KKK // {// uibutton * btn3 = [uibutton buttonwithtype: uibuttontypecustom]; // btn3.frame = cgrectmake (20, 24,101, 80); // btn3.backgroundcolor = [Uicolor clearcolor]; // btn3.backgroundcolor = [uicolor yellowcolor]; // [btn3 addtarget: Self action: @ selector (<# selector #>) forcontrolevents: uicontroleventtouchupinside]; // [self. view addsubview: btn3]; //} // button-(void) backbtn {[self gzybutton: @ "backbtn" andframe: cgrectmake (5, 25, 70, 35) andaction: @ selector (Back :)]; [self Japan tfram: cgrectmake (50, 74, 50, 60) andaction: @ selector (gzyainext :) ];} // Button method-(void) Back :( uibutton *) sender {[self. navigationcontroller popviewcontrolleranimated: Yes];}-(void) jumpad :( uibutton *) sender {adviewcontroller * adview = [[adviewcontroller alloc] init]; uinavigationcontroller * Navi = [[uinavigationcontroller alloc] runtime: adview]; [self presentmodalviewcontroller: Navi animated: Yes];}-(void) gzyainext :( uibutton *) sender {viewcon Troller3 * viewctrl = [[viewcontroller3 alloc] init]; [self. navigationcontroller pushviewcontroller: viewctrl animated: Yes];} // view-(void) creatview {[self gzyview: @ "bg_01_01" andfram: cgrectmake (0, 64,320,418)]; [self gzyview: @ "titleview" andfram: cgrectmake (0, 20,320, 49)];} // button-(void) creatbtn {uibutton * BTN = [uibutton buttonwithtype: uibuttontypecustom]; [BTN settitle: @ "advertisiment !!! "Forstate: uicontrolstatenormal]; [BTN settitlecolor: [uicolor purplecolor] forstate: uicontrolstatenormal]; BTN. frame = cgrectmake (0,480,320, 70); BTN. backgroundcolor = [uicolor graycolor]; [BTN addtarget: Self action: @ selector (jumpad :) forcontrolevents: uicontroleventtouchupinside]; [self. view addsubview: BTN];}-(void) viewdidload {[Super viewdidload]; [self creatview]; [self backbtn]; [self creatbtn]; // do any additional setup after loading the view .}

 

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.