0

I am overriding hitTest:withEvent to return self (the bottom most view)-

When returning self - my view will respond to touch events in turn initiating gesture recognizers.

If a gesture is canceled or some set of conditions happened - I want to manually initiate hitTest:withEvent and then return a different view to take care of the same sequence of events/touches that occurred. This is necessary as a gesture recognizer only initiates after hitTest:withEvent returns the gestures view and its state changed to began.

I am not sure how to do this - I thought about manually calling on my subviews

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{

}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{

}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{

}

But I don't have the event parameter (The gesture received it)

Cœur
  • 37,241
  • 25
  • 195
  • 267
Avba
  • 14,822
  • 20
  • 92
  • 192

1 Answers1

0

I think this could not be done, pass touch event to UIGestureRecognizer is private API. But you can pass touch event the bottom most view received to any view you like and do your own gesture recognize.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  UIView* selectView = [self _findMatchView];
  // maybe convert touches to selectView coordinate
  [selectView handleTouchBegan:touches withEvent:event];
}