I have a view which I'll call parentView
which has a subview called childView
. Part of childView
is outside the bounds of parentView
, and childView
has a panGestureRecognizer
attached to it. I have implemented the following in parentView
so that it will recognize touches to childView
even though it's outside of its superviews bounds:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if (!self.clipsToBounds && !self.hidden && self.alpha > 0)
{
for (UIView *subview in self.subviews)
{
CGPoint subPoint = [subview convertPoint:point fromView:self];
UIView *result = [subview hitTest:subPoint withEvent:event];
if (result != nil)
{
return result;
break;
}
}
}
return [super hitTest:point withEvent:event];
}
Yet when I touch or drag childView
, hitTest
is not even being called on the parentView
. Why is this?