I have a strange issue: When I scroll vertically it triggers swipe right/left events.
I've checked it on iOS...
The swipe events are bound to the data-role='page'.
you can try configuring the horizontalDistanceThreshold to a higher value to allow more horizontal movement when scrolling.
Related
I have scroll view with both horizontal and vertical scrolls (PDF View).
So I wanted to add diagonal swipe to that and figured out that after this:
scrollView?.panGestureRecognizer.require(toFail: swipe)
swipe works, but whole scroll view started reacting only to 2-finger gestures.
So it would be perfect for me to find a solution to remove this conflict of swipes.
My application consists of multiple pages by scrolling horizontally - done by having 2 swipe gesture recognizers over the whole ViewController. On every page I have a ViewTable with items that scroll vertically.
Unless I do a perfect horizontal swipe, the TableView takes over the recognition and does a slight vertical scroll on the table rows.
How do it change the scrolling recognition angle for TableView? Because the table's vertical scrolling is responding from touches around 10º ~ 170º. Whereas I'd like them to be 45º for each direction. How do I narrow that angle? So that my main left/right pages respond easier without having to try to do a perfect horizontal swipe.
I have not really made such a gesture but this is how I think this can be achieved. This is similar to ViewPager on Android. You can use a normal Gesture Recognizer over UITableView, calculate how much x and y displacements are there and then decide whether you want to handle the horizontal scroll yourself by shifting the page or pass the control down to UITableView.
But if you keep your Gesture Recognizer below UITableView, you will never get the control to act upon the gesture unless UITableView passes down to you.
I have a scroll view .I want to scroll it in both direction horizontal and vertical.But when i am scrolling the subview is bouncing as both scrolling are enabled. how to mange this issue like when i am scrolling the view vertically,horizontal scroll should be disabled.
Set the directionalLockEnabled property to YES.
However,
If the drag direction is diagonal, then scrolling will not be locked
and the user can drag in any direction until the drag completes.
Set scrollview.directionalLockEnabled to YES
Note: If this property is NO, scrolling is permitted in both
horizontal and vertical directions. If this property is YES and the
user begins dragging in one general direction (horizontally or
vertically), the scroll view disables scrolling in the other
direction. If the drag direction is diagonal, then scrolling will not
be locked and the user can drag in any direction until the drag
completes. The default value is NO
I essentially want a UITextView to scroll vertically but not ever be able to accidentally scroll the UIPageViewController when the gesture occurs within the UITextView.
I do still want the page turning gesture to work along the edges though:
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.