Context:
I have a UIPageViewController with 4 UIViewControllers, a sort of SnapChat style.
In 3 of those 4 UIViewControllers, I have a UITableView or a UICollectionView, two controls that inherit of UIScrollView.
The problem:
When I scroll (vertically) a UITableView or a UICollectionView, I cannot scroll horizontally (swipe) to the next page until the scroll is finished. Instead, when I try to swipe, the scrolling stops and then I have to do another swipe to actually change the page of the UIPageViewController.
What I expect:
The user has to be able to change the page when swiping, even if the UITableView or UICollectionView is still scrolling, as SnapChat currently does.
Any tips to achieve this?
Thanks!
I believe your issue is that your scroll view has an active gesture recognizer firing when you are scrolling, so the other gesture isn't being identified. I found this as a solution: How to have a UIScrollView scroll and have a gesture recognizer?
Related
I am using UIPageViewController for showing different viewControllers as tabs.
In my child view controllers I have vertical as well as horizontal scrolling content, so I think UIPageViewController is disabling Pan Gesture.
So I am not able to change current view by swiping left or right.
My pageViewController also returns nil for self.pageController.gestureRecognizers
I know that UIPageViewController already has UIPanGesture to change views.
So how can I enable or achieve swipe to change view in my UIPageViewController?
According to screenshot I have tabs at the top and my child view controllers are vertical scrolling and I have few sections with horizontal scrolling content.
Any help would be much appreciable.
Thanks
In one of my app, I am having multiple table views inside a horizontal scroll view. So, user can horizontally swipe between table views. I am not using UIPageViewController for some reason.
The problem that I am facing is that I have swipe to delete feature on my UITableView but does not work when I have multiple pages in the horizontal scroll view.
Is there an elegant way to provide both the features at the same time?
You can subclass UIScrollView and implement UIGestureRecognizerDelegate. Then return true in gestureRecognizer(_:,shouldRecognizeSimultaneouslyWith) for the appropriate recognizers.
I've seen people with similar problems here, but couldn't find any working solution. I have a UICollectionView, with fullscreen cells. I scroll the content horizontally (paging enabled). Each cell has a UIScrollView as a subview, which covers the entire cell. My problem is that when I use zoom-in functionality of a UIScrollView, I can't scroll from one cell to another unless I zoom-out to 1.0 scale or reach a border of a UIScrollView content. My idea was to use two-fingers pan gesture to scroll the collection view, so I could use one finger to scroll cell's internal UIScrollView. It doesn't work and I simply have no idea why. I can provide more details, but for now I don't know what might be important.
I've got 2 (circular) UICollectionviews in my view, both are functioning but I want to use 1 swipe gesture for both views so when I swipe on the top collectionview, the bottom view should also swipe with the same speed and vice-versa. What would be the best way to achieve this?
This is my UIViewController:
both collectionviews should scroll whenever I scroll anywhere on this UIViewController. Any help would be very appreciated.
Set scrollView delegate of your collectionView's scrollView. UICollectionView is a subclass of UIScrollView.
Use scrollViewDidScroll method. In that method you can for example see contentOffset of one UICollectionView and then set contentOffset to the other collectionView's scrollView to that value.
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