In one of my view controllers I have several views that contain a UITapGestureRecognizer, along with an implementation of touchesBegan
. I need to prioritize the taps over touchesBegan
so I set the delaysTouchesBegan
property of the gesture recognizers to YES
. This works correctly, but there's one problem: the gesture recognizer delays touchesBegan
for too long. According to the documentation:
When the value of the property is YES, the window suspends delivery of touch objects in the UITouchPhaseBegan phase to the view. If the gesture recognizer subsequently recognizes its gesture, these touch objects are discarded. If the gesture recognizer, however, does not recognize its gesture, the window delivers these objects to the view in a touchesBegan:withEvent: message (and possibly a follow-up touchesMoved:withEvent: message to inform it of the touches’ current locations).
The problem basically is that when the gesture recognizer does not recognize the gesture and delivers these objects to touchesBegan
, that operation takes too long. Is there anyway to expedite it, or is it just that the processing of the gesture to determine whether it's a tap is intensive and is impossible to shorten?
Edit:
Here's some more info. This is the code I use to setup the gesture recognizer:
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tapRecognizer.cancelsTouchesInView = NO;
tapRecognizer.delaysTouchesBegan = YES;
tapRecognizer.delegate = self;
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.numberOfTouchesRequired = 1;
[self.someView addGestureRecognizer:tapRecognizer];
I'd solve it with changing
UITapGestureRecognizer
toUILongPressGestureRecognizer
. The title of those two is a bit misleading but withUILongPressGestureRecognizer
you can set theminimumPressDuration
: