我有一个视图,我会调用parentView它,它有一个名为childView. 的一部分childView在 的范围之外parentView,并附childView有一个。panGestureRecognizer我已经实现了以下内容,parentView以便childView即使它超出其超级视图范围,它也能识别触摸:
- (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];
}
然而当我触摸或拖动时childView,hitTest甚至都没有被叫上parentView。为什么是这样?