1
votes

I have a simple UIView used like container. If I write this code:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

    UIView *hitView = [super hitTest:point withEvent:event];

    NSSet *sTouches = [event touchesForView:self];

    NSLog(@"Touches %d", [sTouches count] );

    return self;
}

Doesn't work! I would like get touches count in hitTest() message, before touchesBegan()! Is it possible?

I have this hierarchy:

UIView 
  +---> UIScrollView 

When touch on my UIView (single tap) the container moves. When I double touch (two finger) on my UIView, the child UIScrollView doesn't work for Zoom (for example). So I have think to catch touches number.

If touch number is equal to one, hitTest on my UIView container return "self". Else, if touch number is great to one ( == 2), hitTest return "scrollview" pointer.

In others words, I would like catch two finger event into hitTest() message/event.

1

1 Answers

1
votes

hitTest is used by the framework to determine which view is being hit, and thus which view to send the touchesBegan/touchesMoved/touchesEnded/touchesCancelled messages to. At the point hitTest is called, you can't tell.

Maybe you could explain what you are trying to accomplish, because this doesn't seem like the right way to do it.