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
。どうしてこれなの?