Details on iOS event delivery and processing

Source: Internet
Author: User

1. Event handling is a two-step process:

1) Find the appropriate object, this time from the parent control to the child control;

2) Handling events from child space to parent control

Note: If a view is a sibling relationship, then the view is added first (if you add a view using Stroyboard, and then the first response is added). You can now override the Point:inside and Hit:test methods of the parent class to experiment

1-(uiview*) HitTest: (cgpoint) point withevent: (Uievent *)Event2 {3 4     5UIView * Resultview = [Super Hittest:point withevent:Event];6     7NSLog (@"%s", __func__);8     returnResultview;9 Ten } One-(BOOL) Pointinside: (cgpoint) point withevent: (Uievent *)Event A { -      -NSLog (@"%s", __func__); theNSLog (@"red==%d", [Super Pointinside:point Withevent:Event]); - //return [Super Pointinside:point withevent:event]; -     returnNO; -  +}

This can be seen if the green view is added first, then the red point inside method is called first, if all the view on the red view is overridden by this method, and return yes, then the green view of the touch event will not be received, This is the equivalent of forcing the event to be received. note in the actual development generally do not write this, generally rewrite the Pointinside method is to avoid the child control and let the parent control to respond to the touch event, then return no, if there is no need to override this method, if you really need to rewrite the parent class to return the [super Pointinside:point Withevent:event];

Details on iOS event delivery and processing

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.