I am trying to implement zooming and panning on a 2-page UIPageViewController in landscape mode. I have set a scrollview as the view of parent viewcontroller of the pageviewcontroller. This allows the pageviewcontroller to zoom, but not to pan. Is this the correct approach to implementing zooming and panning for UIPageViewcontroller or what approach should I take please?
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
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?
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
I am working on application in which i need to zoom the scroll view on shake effect so user will not touch the screen to pinch or double tap.
I have implemented the code by looking in to this tutorial:
Zoom UIScrollView with multiple images
I got the call in a delegate:
viewForZoomingInScrollView
But the image view not zoom in or out.
When i touch the screen after the delegate called the scroll view is zoom in. But content in scroll view not zoom in or out. It remains as it is.
Even some time i did not get call in the following delegate:
scrollViewDidZoom
scrollViewDidEndZooming
So do i need to call layout subview after viewForZoomingInScrollView if yes where?
From my understanding the view is not zooming because i have not pinch or double tap the scroll view.
Please help me out.
Those you mentioned are UIScrollView delegate methods and they are called when the scrollView will\did actually zoom, not to perform the zooming.
To perform the zoom programmatically you need to use zoomToRect:animated: and passing the portion of your scorllView's subview you want to scroll and wether it needs to be animated or not.
Hope it helps.
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.