Event Response chain and Event Response

Source: Internet
Author: User

Event Response chain and Event Response

The process of Event Response chain: the first responder ---> superview ---> viewCtrl ---> UIWIndow ---> UIApplation ---> Appdelegate. The event is transmitted from the bottom up. If the link is not processed, it will be passed to the next link. If it is not processed, it will return to the UIApplication. If it is not processed, it will be discarded.

The process of calculating the first responder is to take the following steps. iOS system ---> UIApplation --> UIWindow --> viewCtrl --> superView --> ...... subview

When the OS detects a touch operation, it will Package A UIEvent object and put it in the Application queue. The Application extracts the event from the queue and submits it to UIWindow for processing. UIWindow will use hitTest: withEvent: method to recursively find the view where the Operation's initial point is located. This process becomes hit-test view.

HitTest: withEvent: The process of the method is as follows: Call the pointInside: withEvent of the current view: method to determine whether the touch point is inside the current view. If NO is returned, hitTest: withEvent: returns nil. If YES is returned, hitTest: withEvent: message is sent to subViews in the current view. The traversal order of all subViews is to traverse forward from the end of the array, until a subView returns a non-empty object or the traversal is complete. If a subView returns a non-null object, the hitTest method returns this object. If each subView returns nil, it returns itself.

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.