I. Basic concepts of events
1. An event is an object that the system constantly sends to the application when the user's finger touches the screen and moves on the screen
2. The system passes an event to a specific path to an object that can be processed
3. In iOS, a Uitouch object represents a touch, and a Uievent object represents an event. The event object contains all objects that correspond to the current multi-touch sequence, and can also provide touch objects associated with a particular view or window
Two. Basic concepts of touch
1. Touch information has both time and space, and the time information is called the stage (phrase), indicating whether the touch has just begun, is moving or at rest, and when it ends----that is when the finger is lifted from the screen.
2. Touch information also includes current position information in the View or window, as well as previous location information, if any. When a finger touches the screen, the touch is associated with a window or view, and the association is maintained throughout the life of the event.
1. When one or more fingers touch the screen, send the [touchesbegan:withevent:] Message
2. Send the [touchesmoved:withevent:] message when one or more fingers move on the screen
3. Send [touchesended:withevent] message when one or more fingers leave the screen
Three. Responder Chain
1. The responder chain is a connection sequence for a responder object, and an event or action message (or menu-editing message) is passed at a time. It allows the responder object to transfer responsibility for event handling to other higher-level objects. The application finds the appropriate processing object by passing an event up. Because click Detection view is also a responder object, the application can also take advantage of the responder chain when dealing with touch events.
2. A chain consisting of multiple responder objects.
All objects in the 3.iOS that respond to events (touch, shake, remote events) are responders.
4. The system defines an abstract parent class Uiresponder to represent the responder. Its subclasses are the respondents.
Detection sequence:
UIApplication->uiwindow, Rootviewcontroller->viewa->viewb
VIEWC->viewd->viewe (Touch view detected)
Response Order:
The exact opposite of the detection sequence.
1. When a responder is detected, implement Touchesbegan:withevent: The process of handling the event
2. If the responder does not handle the event, the event is passed down. Drop Touch Event If no responder is processed
3. The sequence of event handling is the opposite of a touch detection query
4. Touch the Child view->view->viewcontroller->window->uiapplication
Responder Chain processing principle:
1. Click Detect View or the first responder passes the event or action message to its view controller (if any), if there is no view controller, pass it to his parent view
2. If a view or its view controller cannot handle this event or action message, it is passed to the parent view of the view
3. Each successive parent view in this view hierarchy follows the above pattern if it cannot handle this event or action message
4. Topmost view if this event or action message cannot be processed, it is passed to the UIWindow object to handle
5. If the UIWindow object cannot be processed, it is passed to the single-piece Application object UIApplication, and if the Application object cannot handle the event or action message, it will be discarded
Four. Gestures
1. Gesture recognizer is the encapsulation of touch events, the gesture recognizer itself plays a role in recognition
2. Gesture recognizer is an abstract class in iOS that identifies a gesture called a gesture: a regular touch
Gesture Classification:
ios-Event Handling