I am attempting to implement a UIScrollView where horizontally panning scrolls through pictures in the scrollview but vertically panning performs another action I have. Right now I have a UIScrollView that is paginated with vertical scrolling disabled that works just fine for scrolling through pictures, but am going crazy trying to find a way to intercept vertical pans and call my own method instead of the vertical pans just being eaten up by the scrollview. I was able to do
UIPanGestureRecognizer *panUp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
[self.scrollView addGestureRecognizer:panUp];
[scrollView.panGestureRecognizer setEnabled:NO];
Which gives me total control over the panning in my handlePanGesture: method, but this isn't particularly helpful because then I feel like I am essentially going to be rewriting all the scrolling logic which I am trying to avoid. Any help or guidance on how to achieve this would be greatly appreciated.
Thanks!
shouldRecognizeSimultaneouslyWithGestureRecognizer
toreturn YES
will work for this but you MUST also set your pan gesture.delegate
toself
. I left out setting the delegate and it wasn't working for me. I see you left out the delegate in your code above too. Hopefully this helps future users. – Albert Renshaw