IOS Objective-c Learning Note control gets the button call

Source: Internet
Author: User

There are two ways to get control:

1. Iboutlet: Directly drag and drop the required controls to the interface design file *.h between @interface and @end

2. Tag: Set tag to 12, get lable by the following code

uilabel* lable = (uilabel*) [Self.view viewwithtag:];

The call to the button, and also for iOS, is handled in two ways:

1. Implementing event handling via Ibaction bindings

is still a drag control to *.h, enter the Ibaction method name, connect! And within the control interface *.M file implementation:

-(Ibaction) MYBTN2: (ID) sender {    [self.mytxt setText:@ "aaa"];}

2. Setting events through code

The reference is first obtained by getting the two methods of the control, and then in the-(void) Viewdidload:

[Self.mybtn addtarget:self Action: @selector (Btnhandler:) forcontrolevents:uicontroleventtouchupinside];

And new method Btnhandler:

-(void) Btnhandler: (UIButton *) sender{    [self.mytxt setText:@ " Yes, that's right . " ];}

IOS Objective-c Learning Note control gets the button call

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.