Navigator-page loading

Source: Internet
Author: User
When the right shift is performed, the negative number is supplemented by 1, the positive number is supplemented by 0, and the sign bit is supplemented; the left shift is supplemented by 0; the shift can be used to take the number. When bit operations are performed, it is best not to use (+-*/) Shell Gg = g alignment command d to exit the program scope: variables defined in composite statements can only be used in composite statements. the attributes, member variables, and methods defined in the M file can only be accessed in the current class, but not open out. // The principle of object-oriented programming: the principle of open and closed, the principle of open and closed, open to internal, closed to external # import "appdelegate. H "# import" fisrtviewcontroller. H "@ interface appdelegate () @ end @ implementation appdelegate-(bool) Application :( uiapplication *) Application didfinishlaunchingwithoptions :( 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]; // declare a View Controller to load fisrtviewcontroller * fviewcontroller = [[fisrtviewcontroller alloc] init]; fviewcontroller. view. backgroundcolor = [uicolor bluecolor]; // define a navigator to load the first view controller, that is, with the View Controller uinavigationcontroller * navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller: fviewcontroller]; self. window. rootviewcontroller = navcontroller; return yes;} // The implementation file of the first View Controller class # import "fisrtviewcontroller. H "# import" secondviewcontroller. H "@ interface fisrtviewcontroller () @ end @ implementation fisrtviewcontroller-(instancetype) initwithnibname :( nsstring *) bundle :( nsbundle *) handle {self = [Super initwithnibname: Bundle: nibbundleornil]; If (Self) {// custom initialization} return self;}-(void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view. // Add a label and button uilabel * label = [[uilabel alloc] initwithframe: cgrectmake (0, 64,100, 30)] To the View Controller; label. TEXT = @ "I Am a label"; label. textcolor = [uicolor redcolor]; label. backgroundcolor = [uicolor whitecolor]; [self. view addsubview: Label]; uibutton * nextbtn = [uibutton buttonwithtype: uibuttontypecustom]; nextbtn. frame = cgrectmake (220, 64,100, 30); [nextbtn settitle: @ "nextview" forstate: uicontrolstatenormal]; [nextbtn settitlecolor: [uicolor graycolor] forstate: uicontrolstatenormal]; nextbtn. backgroundcolor = [uicolor redcolor]; [nextbtn addtarget: Self action: @ selector (nextdidclik :) forcontrolevents: uicontroleventtouchupinside]; [self. view addsubview: nextbtn]; uiimageview * imageview = [[uiimageview alloc] initwithframe: cgrectmake (30,144,240,296)]; imageview. image = [uiimage imagenamed: @ "1.png"]; [self. view addsubview: imageview];} // when the button is triggered, it is loaded to the second view controller-(void) nextdidclik :( uibutton *) sender {secondviewcontroller * secondviewcontroller = [[secondviewcontroller alloc] init]; secondviewcontroller. view. backgroundcolor = [uicolor yellowcolor]; [self. navigationcontroller pushviewcontroller: secondviewcontroller animated: Yes];} // implementation file of the second view controller class # import "secondviewcontroller. H "@ interface secondviewcontroller () @ end @ implementation secondviewcontroller-(instancetype) initwithnibname :( nsstring *) bundle :( nsbundle *) handle {self = [Super initwithnibname: Bundle: nibbundleornil]; If (Self) {// custom initialization} return self;}-(void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view. uibutton * beforebtn = [uibutton buttonwithtype: uibuttontypecustom]; beforebtn. frame = cgrectmake (0, 64,100, 30); [beforebtn settitle: @ "beforeview" forstate: Unknown]; [beforebtn settitlecolor: [uicolor graycolor] forstate: uicontrolstatenormal]; beforebtn. backgroundcolor = [uicolor redcolor]; [beforebtn addtarget: Self action: @ selector (beforebtn :) forcontrolevents: uicontroleventtouchupinside]; [self. view addsubview: beforebtn];} // when the button is triggered, return to the previous View Controller-(void) beforebtn :( uibutton *) sender {[self. navigationcontroller poptorootviewcontrolleranimated: Yes];}

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.