Transfer control between two UIPanGestureRecognizer without lifting finger - ios

I have a WKWebView and a header above it that I would like to scroll away when the user pans the scroll view (similar to how Google Chrome/Safari work).
I've added my own pan gesture on top of the WKWebView so I can capture touches and prevent WKWebView's scrollView from scrolling by resetting the contentOffset each time the user pans while the header is visible.
I would like to be able to turn on and off the builtin scrollView's panGestureRecognizer while continuously panning.
Is there a way I can enable/disable pan gestures and have they respond without restarting the pan gesture?

Related

How to make a UIScrollView, some UIButtons and UIPanGestureRecognizer work together?

I got a scroll view with a bunch of buttons, which I want to both touch and drag.
To choose if it's a touch or a drag (not drag of the scroll view, "physically" dragging the button), I check the pan gesture recognizer of the button to see how far away the drag would be, if it's over a threshold I snap the button into drag mode and, removing it from the scroll view and adding it to my view controller's view (at the same location, so looks like it's in the same place).
This all works kinda smooth, except when I want to scroll and the pan fires at the same time. I need a way for the pan gesture recognizer to choose, based on velocity, if the scroll view should scroll or the button should be dragged.
The question: Is there a way for a UIPanGestureRecognizer to tell a UIScrollView to continue scrolling and cancel itself?

Cancel UIGestureRecognizer if subview contains gesture?

I was originally using the UITouch methods (touchesMoved: withEvent:) in order to detect the movement in a view. Due to the fact that it seemed not to update often enough I switched to using a UIPanGestureRecognizer (though this didn't actually fix the initial problem).
After using this the touches received for movements responded no matter what it was touching (different subviews) which I actually prefer. However now I have an issue with all the subviews which have movement. I need the gesture recognizer to still move the view even while touching subviews, however if the subview also moves in this direction (left/right) I need my recognizer to cancel.
It seems like gestureRecognizerShouldBegin: might be somewhere to start, but in my case, I cannot account for all subviews.
Is it possible to make pan gesture recognizer cancel if the subview (i.e. another pan recognizer, UISlider, horizontal scrollview, etc.) touched needs to be moved in left/right directions without having to account for each subview individually?

Zooming and moving a UIScrollView at the same time

I have a UIScrollView that takes up a portion of the screen, and its basic functions (scrolling and zooming) work just fine. For example, I can grab the scrollview with two fingers, and scroll left and right, while zooming in or out on the content.
I want to add the ability to move the UIScrollView up and down at the same time. Please note that I do not want to move the content of the scroll view, but the scroll view itself.
I have attempted to add a UIPinchGestureRecognizer to the UIScrollView which has allowed me to grab and move the scroll view, but I then lose the zoom and scrolling. It seems that adding a gesture recognizer makes all of the default actions stop (also, when I call setZoomScale, I get an EXC_BAD_ACCESS).
I've also considered checking touches, but touches on the UIScrollView aren't registered with the main view so I can't change its location using those values.
Does anyone have any suggestions on how this might be accomplished?

UIWebView override swipe gesture

I have a UIWebView that loads a page that captures left/right swipe gestures. So all swipe gestures are eaten up by the UIWebView, meaning that these gestures do not work within my app.
How do I:
Prevent the UIWebView from eating the left/right gestures, but still process all other events (such as swipe up/down to scroll)
Pass a two-finger swipe through to the UIWebView as a one-finger swipe.
Even if (1) is possible, that would be excellent!
Thanks!
you can use
[self.view gestureRecognizers]
this will give you an array of the gesture recognisers from here you should be able to remove or change the action of the gesture recogniser.

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