I am creating a custom UIView and adding a UITapGestureRecognizer on it. I have a handler for the tap gesture. But at the same time I want my UIView to listen to touchesBega
You need to set cancelsTouchesInView
(and likely delaysTouchesBegan
and delaysTouchesEnded
) to NO
for the gesture recognizer. The default behavior of a gesture recognizer is to avoid having both it and the view process the touch. These settings let you fine-tune that behavior.
As stated earlier, you need to set the cancelTouchesInView
property to NO
on your UITapGestureRecognizer
.
From the Apple Docs:
cancelsTouchesInView—If a gesture recognizer recognizes its gesture, it unbinds the remaining touches of that gesture from their view (so the window won’t deliver them). The window cancels the previously delivered touches with a (touchesCancelled:withEvent:) message. If a gesture recognizer doesn’t recognize its gesture, the view receives all touches in the multi-touch sequence.
Further reading: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/