How to add UIPanGestureRecognizer to UIScrollView subviews?

The problem is that the pan gesture recognizer is what is used in the scroll view to control scrolling. Your gesture recogniser is taking priority and disabling the scroll views.

Up vote -2 down vote favorite share g+ share fb share tw.

I am adding subviews to a UIScrollView and then I add UIPanGestureRecognizer to these subviews. Everything works fine but now after adding UIPanGestureRecognizer to subviews of the scroll view, scrolling is not possible. What can be the possible solution to this issue?

Iphone ios uiscrollview uipangesturerecognizer link|improve this question edited Feb 4 at 12:28Costique8,7321129 asked Feb 4 at 12:17Shubham214 100% accept rate.

– sgermain06 Feb 4 at 12:34 1 possible duplicate of Scrolling is disabled when I add A UIPangesturerecognizer to UIScrollView – rob mayoff Feb 4 at 18:54 1 You asked exactly the same question three hours before asking this one. – rob mayoff Feb 4 at 18:54.

The problem is that the pan gesture recognizer is what is used in the scroll view to control scrolling. Your gesture recogniser is taking priority and disabling the scroll views If you want to always be able to scroll you can set your gesture recogniser to require the scroll views one to fail before it will work: self. MyCustomPanRecognizer requireGestureRecognizerToFail:self.scrollView.

PanGestureRecognizer; Edit: as Bastian pointed out in the comments, the reference to pan guesture is only in iOS 5, prior to this, check the array of gesture recognisers and find the one of type UIPanGestureRecognizer if you want both to work you may need to do something to separate your recogniser from the scroll views, e.g. Make the user tap and hold before your custom recogniser will be recognised. There is also a delegate method which will allow both recognisers to work together, but I'm not sure how well this works when both are the same type.

Scrollview. PanGestureRecognizer is only available from ios5 .. if you want to support ios4 you can get the gesture recognizers from the scrollview and check the class to get the pangesturerecognizer. – Bastian Feb 4 at 18:53 thanks @Bastian, I didn't realise it was iOS 5 only, answer updated – wattson12 Feb 4 at 20:39.

If you want to use both simultaneus you can use - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer from the delegate, but that is probably not what you want ;).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions