I'd be interested in seeing other solutions, but the easiest way I know of is to override either of these two UIView methods:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event;
These methods get called to determine if the touch is within the bounds of the view or any of its subviews, so this is a good point to intercept the touch and then pass it on. Just do what ever you want, and then
return [super hitTest:point withEvent:event];
or
return [super pointInside:point withEvent:event];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…