IOS code creates controls and has handling events

Source: Internet
Author: User

@interface appdelegate () @property uilabel* Show; @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];    Create a Uiviewcontroller object uiviewcontroller* controller = [[Uiviewcontroller alloc] init];    Let the program's window load and display the user interface associated with the Viewcontroller view Controller Self.window.rootViewController = controller;    Create a UIView object uiview* rootview = [[UIView alloc] initwithframe:[[uiscreen mainscreen] bounds]];    Set controller display Rootview control Controller.view = Rootview;    Create a rounded button uibutton* buttons = [UIButton buttonwithtype:uibuttontyperoundedrect];    Set the size of the button Button.frame = CGRectMake (120, 100, 80, 40);    Set the text for the button [button settitle:@ "OK" forstate:uicontrolstatenormal];   Add a button to the Rootview control [Rootview Addsubview:button]; Create a UILabel object self.show = [[UILabel alloc] Initwithframe:cgrectmake ($, +, +)];//uilabel* show = [Uilab    El Alloc] Initwithframe:cgrectmake (60, 40, 180, 30)];    Add Uilabel to the Rootview control [Rootview AddSubview:self.show];    Sets UILabel default display of text Self.show.text = @ "initial text";    Self.show.backgroundColor = [Uicolor Graycolor]; Event handling method for touch event binding for Fillet buttons [button addtarget:self action: @selector (ClickHandler:) forControlEvents:        UIControlEventTouchUpInside];    Set the UIWindow object as the main window and display it [Self.window makekeyandvisible]; return YES;}


-(void) ClickHandler: (ID) Sender {    Self.show.text = @ "Start learning IOS!" ";}


IOS code creates controls and has handling events

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.