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