How to intercept vertical swipe gestures - ios

Is there a way to insert my uitableview into the responder chain so I can process some vertical swipes (based on horizontal position) and pass others on to the underlying uiscrollview?

I ended up making my own Gesture Recognizer as explained in this post: Pan gesture interferes with scroll

Use a UISwipeGestureRecognizer on the view, configure the direction to be up and down(vertical)

Related

UIScrollView - scroll or swipe?

In my app I have a UIScrollView and I need to swipe left and right from one picture to the next, but I also need to recognize a scroll.
How do I differentiate between a scroll and a swipe with UIScrollView?
I believe you're actually looking for is an implementation of UIScrollView with Paging, as you do not need to handle the touch events yourself, or determine if they are scrolls or swipes.
The Apple Documentation on Scroll Views and Paging Mode should help you get started
Look into the UIScrollView Delegate Methods. ScrollView can detect different types of actions drag etc or add swipeGesture directly to the scroll view
StackOverflow has questions already on this
iOS: UIScrollView detecting Swipe Gesture
Setting up UIScrollView to swipe between 3 view controllers
How to recognize swipe gesture in UIScrollView

Drag Gesture Recognizer interfere with swipe Gesture Recognizer

I have a problem about gesture recognizer. I have two gesture recognizers in my view, one added to the background superview to swipe to change background color, the other one is added to a subview which could be dragged around.
The problem is the drag gesture is interfered with the swipe. When I drag the view around, in some case, drag operation will be recognized as a swipe and trigger the swipe operation. I don't want this, I just want swipe could be recognized after finish this drag operation. This situation is more often when I drag the subview around quickly. Every time during the drag, the swipe operation will be triggered.
You need to setup your lesser UIGestureRecognizer with requireGestureRecognizerToFail: and pass your recognizer that you want to be important to it.
UIView *subview = ....
[self addSubview:subview];
[self.gestureRecognizer requireGestureRecognizerToFail:subview.gestureRecognizer];

UIPanGestureRecognizer requireGestureRecognizerToFail delays UIScrollView

i have a UIPanGestureRecognizer on my rootViewControllers view
that controls only 2 finger swipe ( min and max are set on 2 )
I have a couple of UITableView and UIScrollView on my rootViewControllers view.
But the 2 finger swipe should always have number 1 priority
so i put a requireGestureRecognizerToFail on my UITableView and UIScrollView's panGesture property.
this works perfectly but now when i pan my UITableView and UIScrollView, it doesn't move until i stop swiping.
Is there a solution for this?
i have added a sample project to display what the problem is: https://github.com/avalanched/UIScrollViewTest
You will need to allow the gesture recognizers to simultaneously recognize by setting the delegate on all the gesture recognizers and implementing gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:.
See Apple's UIGestureRecognizerDelegate Documentation.
You also need to remove the requireGestureRecognizerToFail calls, these are what causes the delay.

UIPanGestureRecognizer with UIScrollView

I've been fighting with UIScrollView for a while now.
I have a scroll view which has multiple 'card' style views in it. I want the cards to move vertically, as in swiping up and down.
Imagine MobileSafari's tab view, but with swipe down to close tabs.
I can't figure out how to do this without it conflicting with the scroll view horizontal panning. I either get them both panning, or only one panning (vertical / horizontal).
What's the best practice to make this work perfectly, as in "if you're swiping vertically, stop horizontal swiping, and if you're swiping horizontally, stop vertical swiping".
Thank you!
Here's an illustration of what I want :
The scroll view has its own gesture recognizer: see its panGestureRecognizer property. If you add your own recognizer for detecting the vertical swipe, you can use requireGestureRecognizerToFail: or delegate methods to manage dependencies between the two recognizers.
I'm really confused by the intended behaviour of your app here. You are using swipe and panning interchangeably but they are different gesture recognizers.
Well one way to differentiate is to compare the x and y values of the translationInView: method of the gesture. If y > x, you have a vertical swipe/pan; x > y and you have a horizontal swipe/pan.
Make that gesture recognizer fail if the swipe/pan detected is not the type you are looking out for.

UIScrollView zoomed won't produce swipe

I have a UIScrollView with zooming enabled, and a swipe gesture recognizer setup. When the user is not zoomed, the swipes come through great, but as soon as the user zooms in, the swipe won't come through.
My swipe recognizer is applied to the imageview, and I have tried to apply it to the scroller also. When zoomed, no go.
Is there a secret to getting the swipe while zoomed?
Thanks in advance!
Rob
Where is your swipe gesture recognizer?
Have you tried setting scrollView setCanCancelContentTouches:NO?
Is there a secret to getting the swipe
while zoomed?
Yes, there is. Each UIImageView should be inside its own UIScrollView which in turn are inside of main UIScrollView. No gesture recognizers are needed, just set UIScrollViews options like zoom scales etc and implement UIScrollViewDelegate methods for master UIScrollView.

Resources