I use two gesture recognizers on my UIView . One of them is a standard UITapGestureRecognizer , the other is a very simple touch recognizer that I wrote:
@implementation TouchDownGestureRecognizer - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (self.state == UIGestureRecognizerStatePossible) { self.state = UIGestureRecognizerStateRecognized; } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { self.state = UIGestureRecognizerStateFailed; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { self.state = UIGestureRecognizerStateFailed; } @end
They work together only if I assign a delegate to both of them that contains this method:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; }
Everything works fine, but when I press this point for a long time, touch the recognition lights and touch the recognizer. For short taps everything is in order, they both shoot.
I implemented all the methods in UIGestureRecognizerDelegate to return YES to no avail. If I add logging to see the interaction with the delegate and inside my own recognizer, I see that for short and long taps the call sequence is identical - except for the call to direct the recognizer. What am I doing wrong?
source share