Mono touch registration event Methods

Source: Internet
Author: User

1. attach an anonymous delegate: [csharp] testButton1.TouchUpInside + = delegate {new UIAlertView ("TouchUpInside", "TouchUpInside handled", null, "OK", null ). show () ;}; 2.use a lambda expression: [csharp] testButton2.TouchUpInside + = (sender, ea) =>{ new UIAlertView ("Touch2", "TouchUpInside handled", null, "OK", null ). show () ;}; the cancellation event is "-=" 3. assign a delegate method: [csharp] testButton3.TouchUpInside + = HandleTouchUpInside; [csharp] private void HandleTouchUpInside (object sender, System. eventArgs e ){//...} 4. addTarget method: [csharp] btnForgetPwd. addTarget (this, new MonoTouch. objCRuntime. selector ("LoginSelector"), UIControlEvent. touchUpInside); [Export ("LoginSelector")] void OpenPlatform (){//...} the last method reveals that we can create dynamically. In this case, dynamic creation refers to configuration. Just think about it. If we leave the Mobile End alone, we will make some configuration on the pc end, check and select to construct an xml file, parse the xml file, pre-process the button event with a class library, and dynamically bind it with AddTarget. This is very convenient.

Related Article

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.