Event Response chain and Event Response
The process of Event Response chain: the first responder ---> superview ---> viewCtrl ---> UIWIndow ---> UIApplation ---> Appdelegate. The event is transmitted from the bottom up. If the link is not processed, it will be passed to the next link. If it is not processed, it will return to the UIApplication. If it is not processed, it will be discarded.
The process of calculating the first responder is to take the following steps. iOS system ---> UIApplation --> UIWindow --> viewCtrl --> superView --> ...... subview
When the OS detects a touch operation, it will Package A UIEvent object and put it in the Application queue. The Application extracts the event from the queue and submits it to UIWindow for processing. UIWindow will use hitTest: withEvent: method to recursively find the view where the Operation's initial point is located. This process becomes hit-test view.
HitTest: withEvent: The process of the method is as follows: Call the pointInside: withEvent of the current view: method to determine whether the touch point is inside the current view. If NO is returned, hitTest: withEvent: returns nil. If YES is returned, hitTest: withEvent: message is sent to subViews in the current view. The traversal order of all subViews is to traverse forward from the end of the array, until a subView returns a non-empty object or the traversal is complete. If a subView returns a non-null object, the hitTest method returns this object. If each subView returns nil, it returns itself.