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
The touch area is within view a, so Subview B and C of view a are detected;
The touch area is not in view B but within view C, so check the Subview D and E of view C;
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