I am trying to override hitTest: withEvent in a custom view. This is a container view with many areas.
This "supervisor" is a gesture recognizer. In addition to this view, there are many subtitles (which, in turn, have more and more subviews), I decided to overcome hitTesh: withEvent to decide which view should receive events - and in which cases the supervisor should receive an event to trigger a gesture .
The problem I am facing is that hitTest will return a supervisor in cases where the selection gesture is initialized in a preview. In this case, I would like to "retroactively" ignore the action of the crane - and again "invoke" hitTest: withEvent in supervision. the supervisor may then decide to transmit the “true” responder to this event.
How to do it:
Example:
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *v = [super hitTest:point withEvent:event];
if (v == nil)
{
return nil;
}
if ([v isKindOfClass:[UIControl Class]])
{
return v;
}
if (event wouldn't initiate a pan)
{
return v;
}
return self;
}
source
share