Response chains for events in iOS (Responder chain) and delivery chains

Source: Internet
Author: User

Some concepts involved in the response chain of an event

    • The Uiresponder class, which is a base class for handling event responses in Uikit. All events on the window are triggered by the class response (that is, the event is processed in and out). Therefore, the window and the view and controller are derived from the class, such as UIView, Uiviewcontroller and so on.

    • By invoking the method or property provided by the Uiresponder class, we can capture and process all the response events on the window.

    • The responder chain is a chain of multiple responder objects, where the responder object is the object that can handle the event, all view and Viewcontroller are responder objects, and the responder chain enables multiple controls to handle the same touch event.

For example, the responder chain has the following characteristics:

The responder chain is usually started by initial view;

    • UIView's nextresponder its superview; Uiviewcontroller UIView is Nextresponder if UIView is already the top view of UIVIEWCONTR Oller;

    • Uiviewcontroller If there is a super Viewcontroller, then its nextresponder for its super Viewcontroller the most superficial View, if not, then its nextresponder is UIWindow;

    • The contentview of UIWindow points to uiapplication as Nextresponder;

    • UIApplication is the end of a responder chain, its nextresponder points to nil, the entire

      Responder chain end.

hit-test View and hit-testing

Assuming the user touches the View E area, IOS will repeatedly detect subview in the following order to find Hit-test view

    1. The touch area is within view a, so Subview B and C of view a are detected;

    2. The touch area is not in view B but within view C, so check the Subview D and E of view C;

    3. The touch area is not in view D, in view E;

View E is lowest view in the entire view system, so view E is Hit-test view.

There are two chains of events: The response chain of events; Hit-testing the chain of events when the event is passed.

    • Response chain: Passed from the nearest view to the system. Initial view–> Super view–> .....–> view controller–> window–> application–> appdelegate

    • Hit-testing chain: The view passed from the system to the nearest user. Uikit–> Active App ' s event queue–> window–> root view–>......–>lowest view

Response chains for events in iOS (Responder chain) and delivery chains

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.