How can I prevent clipped portions of subviews from still taking touch events?
I'm currently clipping some UIViews w开发者_StackOverflow社区ithin a parent view like in the illustration below:
The problem is that the clipped portions (the invisible portions) of the subviews are still receiving touch events that, intuitively, should be going to the other views visible there.
Is there something else I should be doing to achieve this behavior, or is this not actually an easy thing to do?
This was happening because the parent view in this case had a custom implementation of
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
,
and it wasn't performing this bounds test (which I now assume is part of the default implementation).
Adding:
if ([self pointInside:point withEvent:event]) {
....
}
around the code in that implementation solved the problem.
精彩评论