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.
Related
I would like to achieve an animation when swiping from page to page on a UIPageViewController. I would like this animation to be linked to a UISwipeGestureRecognizer.
My question is: can I calculate a beginning and end of a swipe gesture and relatively execute an CGAffineTransform?
So I during the swipe, I want to transform a view in the direction of the swipe.
Who has any good tutorials or snippets I could use?
A couple of things.
Page view controllers are not built to use custom animations between pages. They are intended to use either a slide animation or a page curl animation.
Second, swipe gestures are single-shot, not continuous. There is no "relatively execute." When you do a swipe gesture, nothing happens, then the gesture fires and it's over. If you want an animation that's proportional to the user's finger position in the gesture you'll either need to do some specialized handling of a pan gesture recognizer or create your own custom gesture recognizer.
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?
I have a UICollectionView that contains a single UIButton in each cell. I've discovered it's difficult to swipe between the horizontal pages because if you touch down on a cell to begin the swipe, the UIButton touch events are triggered instead of allowing the swipe gesture to occur. I do have Delays Content Touches enabled for the collection view. What can I do to solve this so that it will recognize the page pan swipe gesture when you begin swiping on a cell? Perhaps the amount of delay can be increased before it recognizes a UIControl event?
Note that I do need to preserve the touch events for the buttons - I need to know when these events occur: TouchDown, TouchDragEnter, TouchCancel, TouchDragExit, and TouchUpInside.
Without the knowledge of whether you add the gesture recognizer in storyboard or by code, I can only suggest that you can try to creates a dependency relationship between the cell's gesture recognizer and the other gesture recognizer.
- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer
You have to set delaysContentTouches to YES on your UICollectionView. That way, there will be a small delay before the cells will receive a touch, and the built-in swipe recogniser can do its work.
You can also do that from the nib/storyboard by ticking the appropriate checkmark in IB:
It seems this was only a problem in iOS 8.0 (at least the simulator), as I'm no longer experiencing it in iOS 8.1.
Is it possible to detect direction of swipe and simultaneously detect release of finger from screen? When I use gesture recognizer from Object library, it works only swipe or only touchesEnded, but not simultaneously.
Set cancelsTouchesInView to NO on your swipe gesture recognizer. If you're working from interface builder, it's the Canceled in View checkbox.
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.