Scrolling is disabled when i add A UIPangesturerecognizer to UIScrollView

UIScrollView has its own pan gesture recognizer, which controls scrolling. By adding another pan gesture recognizer, you are preventing the scroll view's own pan gesture recognizer from working.

There are a number of ways to deal with this, but it would be helpful if you could explain how the system is supposed to know when the user is trying to dismiss the scroll view, and when he is trying to scroll, since you want a pan gesture to do both.

For example, you could set the delegates of both gesture recognizers to allow the recognizers to operate simultaneously (by overriding the gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: method). You could make each gesture recognizer require a different number of touches (by setting the minimumNumberOfTouches and maximumNumberOfTouches properties). You could use a UISwipeGestureRecognizer to recognize the dismiss gesture. You could detect when the user tries to scroll past the left edge of the scroll view by overriding the scrollViewDidScroll: method of the scroll view's delegate.


You can set priorities of your panGestureRecognizers manually. This is how I solved the same problem: in delegate (BOOL)gestureRecognizerShouldBegin: I made scrolling disable in my scrollView if it should return YES. And in the beginning of a selector of my panGestureRecognizer I made scrolling enabled.

In this delegate you can create a condition of your panGestureRecognizer to enable such a way, that it will be work if and only if you want it to have a major priority.

Tags:

Ios

Iphone

Ipad