3

I have a view controller that it part of a UIPageViewController. Within this view controller, there is a view called pdfView. This view has a UIScrollview.

-UIPageViewController
   -UIViewController
        -pdfView (UIView)
            -UIScrollView

I set the gesture recognizers of pdfView to be the UIPageViewController's gesture recognizers (for turning the page). The only problem is, if the user zooms into the scroll view by pinching, they are unable to move to the right or left of the scroll view because the page turns instead. What do you suggest I do to prevent this from happening? Thanks.

pdfView.gestureRecognizers = self.pageViewController.gestureRecognizers;
Jack Humphries
  • 13,056
  • 14
  • 84
  • 125
  • Setting the view controller's gestureRecognizers instead of the pdfView's somewhat solves this problem (can move throughout the UIScrollView), but the user is unable to swipe to turn the page (code: viewController.view.gestureRecognizers = ...) – Jack Humphries Mar 21 '12 at 04:44

3 Answers3

5

I know my answer is the accepted, but I have tryed to change my UIView to a scrollView and all works better.

when I zoom a page, the pageview gestures of that page stop working, so I can zoom in and out, and pan the zoomed image withouth problem, and when I zoom to the initial scale, the page gestures start to work again automatically.

I have in my dataViewController the view, a full screen scrollerView, and a full screen imageView inside the scroller view.

-UIPageViewController
   -UIViewController
        -UIView
            -UIScrollView
                -UIImageView

So, if you want to change the page while it is zoomed, yo can, you have to choose between pan the zoomed page or change the page with the pan gesture. It was the behabiour I was looking for, in my code I do it manually, but I'm goin to change to the UIScrollView because the UIScrollView pan and pinch gestures work much better than mine.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • I have the exact same problem. Can you give an idea of how you achieved your solution, using the UIScrollView? – Remover Dec 03 '12 at 12:46
  • I just did what I said and it worked without any changes. But it's a scroller view for each page, so you zoom the pages individually if you are in 2 pages mode. Just put an UIScrollView inside the view of the viewController you use for each page. – jcesarmobile Dec 03 '12 at 15:04
3

Try this, instead using a scrollview use a regural UIView Add to this new UIView an UIPinchGestureRecognizer to zoom it and an UIPanGestureRecognizer to move the content. (you have to create the pinch and pan actions, but you can google them)

I did something similar and worked, the only problem is sometimes it detect the page swipe instead the view pan, you can solve is forcing the pan to require 2 touches.

If you have doubts let me know

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
0

I made this library that makes this setup work

-UIPageViewController
   -UIViewController
        -UIView
            -UIScrollView
                -UIImageView

https://github.com/holyman2k/WXPagedPhotoView

the only issue i have is when user zoom the photo, the pageviewcontroller pan gesture is disabled till user scroll the edge and restart panning. you have this weird behaviour that user zoom in the photo, scroll to the very right hand, then scrolling stops, then user scroll again to move to the next page

Charlie Wu
  • 7,657
  • 5
  • 33
  • 40