Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A UIPanGestureRecognizer subclass to recognize immediately. Is this a good idea?
@implementation ImmediatePanGestureRecognizer
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
if (self.numberOfTouches >= self.minimumNumberOfTouches) {
self.state = UIGestureRecognizerStateBegan;
- (void)setState:(UIGestureRecognizerState)state {
// We don't want to enter the begin state if we've already began.
// Need to do this because we're prematurely firing "Began" on touches began
// and UIPGR will fire it somewhere else (presumably -touchesMoved:)
if (self.state == UIGestureRecognizerStateBegan && state == UIGestureRecognizerStateBegan) {
[super setState:state];

This comment has been minimized.

Copy link
Owner Author

jbrennan commented Dec 30, 2015

Blech, although this gets rid of the need for touch movement before it starts, there still seems to be about a 1 second (!!!) delay between when I tell the gesture recognizer to start and when I get my action callback.

Instead, I’m just reverting back to using UILongPressGestureRecognizer with a short duration and a large allowable movement. Works better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.