iOS Development UI chapter-responder Chain

Source: Internet
Author: User

iOS Development UI chapter-responder Chain

One detailed process of touch event handling

A touch event that occurs after a user taps the screen and, after passing through some columns, finds the most appropriate view control to handle the event

Once the most appropriate view control is found, the touches method of the control is called to make specific event handling

Touchesbegan ...

Touchesmoved ...

Touchedended ...

The default practice of these touches methods is to pass the event up the responder chain, handing the event to the previous responder for processing

Second, the response process

The process of delivering a complete touch event with a delivery response

Uiappliction-----UIWIONDW to find the most appropriate control for handling events--the control calls the touches method--and determines if the touches method is implemented-- No implementation by default passes an event to the previous responder--finds the previous responder

Iii. Important Notes

1. Related Concepts

Responder chain: A chain of many responders linked together called the responder chain.

Responder: The object that inherits Uiresponder is called the responder object

2. Principles of Treatment

By default, events are passed up the responder chain, handing events to the previous responder for processing

How can I tell who is the last responder of the current responder?

(1) determine whether the current controller view, if the controller's view on the previous responder is the controller

(2) If the view is not currently a controller, the previous responder is the parent control

3. What is the use of the responder chain?

Allows multiple responders to respond to the event at the same time as a touch event occurs

-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event

{

[Super Touchesbegan:touches Withevent:event];

NSLog (@ "%@", Self.class);

}

Iv. the event delivery process of the responder chain

If the view controller is present, it is passed to the controller, and if the controller does not exist, it is passed to its parent view

In the top-most view of the view hierarchy, if you cannot process the received event or message, it passes the event or message to the Window object for processing

If the window object is not processed, it passes the event or message to the UIApplication object

If UIApplication cannot process the event or message, it is discarded

Supplement: official Apple document

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.