iOS responder Chain

Source: Internet
Author: User

1:The iOS system detects a finger touch (touch) action, packaged as a Uievent object, into the event queue of the currently active application, passed to the singleton UIWindow to handle- > UIWindow Find the first responder through the event distribution mechanism of the responder chain (as shown in the steps)

Figure II

Join the user click on the view E, the following together with the Diagram II Hit-test view of the process:

1, A is the root view of UIWindow, therefore, the Uiwindwo object will be the prime minister of a hit-test;

2, obviously the user clicks the scope is within the range of a, therefore,pointinside:withevent: Returns the Yes, then will continue to check A's child view;

3. At this time there will be two branches, B and C:

The clicked range is no longer within B, so the pointinside:withevent of the B branch : Return no, corresponding to the hittest:withevent: return nil;

Click on the range in C, that is, C pointinside:withevent: return yes;

4. There are two branches of D and E:

Click the range no longer within D, so D pointinside:withevent: Return No, Corresponding hittest:withevent: returns nil;

The range of clicks is within E, which is E's pointinside:withevent: Returns Yes, because E has no child view (it can also be understood that nil is returned when hit-test to the child view of E), so E's hittest:withevent: will return E, Back again, that is the hittest:withevent of C : return e--->>a hittest:withevent: Return E.


2: If the first responder is not found, the current view is traced up through the responder chain to UIWindow and uiapplication, and if neither of them can handle the event, the event will be discarded



iOS responder Chain

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.