开发者

How to receive all touch events that occur in a view hierarchy?

I have a complex view hierarchy controlled by an UIViewController. I'm looking for a simple way to inform the controller about all touches happening inside the hierarchy, even those that are handled by subviews. I don't want to intercept them, I just want to be informed开发者_运维问答 about them.

And subclassing all views in the hierarchy is not really an option.

Thanks!


Subclass root view in your controller and implement hitTest:withEvent: method in it:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    UIView *result = [super hitTest:point withEvent:event];
    // Your custom code
    return result;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜