boostedz06
boostedz06

Reputation: 319

iOS UIPanGestureRecognizer prevents scroll

I am overriding my horizontal image UIScrollView with a panning gesture recognizer to detect a user swipe.

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCaptured)];
[imgHorizontalScrollView addGestureRecognizer:panGesture];

My question is: Is there a way for me to reset imgHorizontalScrollView's pan gesture recognizer back to default in the panGestureCaptured method? The reason I ask is because since I am overriding this gesture, once the user swipes and the gesture is picked up, I am no longer able to scroll in the scroll view. I also tried to remove the gesture but that also prevents me from being able to scroll.

Upvotes: 3

Views: 6106

Answers (2)

Alexey Kozhevnikov
Alexey Kozhevnikov

Reputation: 4259

try UIGestureRecognizerDelegate gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: with scrollView's gestureRecognizer got by panGestureRecognizer

Upvotes: 8

Ismael
Ismael

Reputation: 3937

Try setting

panGesture.cancelsTouchesInView = NO;

If that doesn't work, you should find a way to change your gesture handler to the scrollViewDidScroll: delegate method

Upvotes: 0

Related Questions