Is there a way to conform UIScrollView to custom swipes without changing to 2-finger swipes - ios

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.

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?

multiple view controllers with tableview inside scrollview

I have 3 viewcontrollers inside a UIScrollView that page horizontally. each viewcontroller has a tableview within it.
I can swipe between the 3 viewcontrollers easily when the active table is still (not scrolling) - but when i try to page left or right when the tableview is moving it seems to ignore the touch and gets stuck. I have to stop the tableview with a touch before paging (almost as if the tableview is trying to receive the horizontal gesture)
how can I make my scrollview always react to a horizontal paging
here is a visual of my setup:
tell me if you need any more info
There are multiple ways to get around this.
One way is that you could manage the horizontal scrolling yourself with UIGestureRecognizer. So if there is a left swipe then scroll horizontally to the left and vice versa for right swipe. That way if a UITableViewController is vertically scrolling at the time of the horizontal swipe, it won't have to wait until it is stopped to detect it.

Disable horizontal swipe for UIPageViewController (except at edges)

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:

UIScrollView inside UIScrollView: Scrolling

Setup:
I have a full-screen, parent UIScrollView that has paging enabled. Then I have a small, second UIScrollView inside of the first one, with also paging enabled.
Problem:
If I swipe the second UIScrollView, it scrolls fine untill it runs out of pages, then the parent UIScrollView takes over scrolls. For example, if I am on the last page on the second UIScrollView, swipe to left, the parent UIScrollView begins to scroll to right. I tried enabling exclusiveTouch, but no change.
Question:
Is there a way if I scroll the second UIScrollView, only that will scrolls and stops, the parent UIScrollView will never move from that original swipe?
You can set scrollView.scrollEnabled = NO; when other scroll is moving. You can detect when scroll begin dragging and didScroll.
You can get everything with basic scrolling with full screen view from this one
https://github.com/zvonicek/ImageSlideshow
Trust me it really work and also work at rotating device.

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?

Resources