1. Event handling is a two-step process:
1) Find the appropriate object, this time from the parent control to the child control;
2) Handling events from child space to parent control
Note: If a view is a sibling relationship, then the view is added first (if you add a view using Stroyboard, and then the first response is added). You can now override the Point:inside and Hit:test methods of the parent class to experiment
1-(uiview*) HitTest: (cgpoint) point withevent: (Uievent *)Event2 {3 4 5UIView * Resultview = [Super Hittest:point withevent:Event];6 7NSLog (@"%s", __func__);8 returnResultview;9 Ten } One-(BOOL) Pointinside: (cgpoint) point withevent: (Uievent *)Event A { - -NSLog (@"%s", __func__); theNSLog (@"red==%d", [Super Pointinside:point Withevent:Event]); - //return [Super Pointinside:point withevent:event]; - returnNO; - +}
This can be seen if the green view is added first, then the red point inside method is called first, if all the view on the red view is overridden by this method, and return yes, then the green view of the touch event will not be received, This is the equivalent of forcing the event to be received. note in the actual development generally do not write this, generally rewrite the Pointinside method is to avoid the child control and let the parent control to respond to the touch event, then return no, if there is no need to override this method, if you really need to rewrite the parent class to return the [super Pointinside:point Withevent:event];
Details on iOS event delivery and processing