PDFView usePageViewController(_:withViewOptions:)

So PDFView allows setting the PDFViews scrollView to a UIPageViewController with

usePageViewController(_:withViewOptions:)


Q1. How can I access the PDFViews pageViewController so I can set myself as its delegate so I can receive

pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool)


Q2. how can I change the

UIPageViewControllerTransitionStyle of PDFView when usePageViewController(_:withViewOptions:) is called?

Replies

I am also interested in this, specifically your Q2, but alas I have found no mechanism by which to set the transition style that the PDFView should use, especially as the option is not one of the viewOptions you can specify, and there’s no other way to set it on initialisation. I don’t think this is currently available in the current iOS version 11.2.


I'd rather not have to build an entirely new PDFView using the utility classes, as is hinted at in the docs, so hopefully this is a foresight that will be rectified in a later update of iOS. The whole use of the pageViewController in PDFKit seems a little rushed to me.

You can actually traverse the responder hierarchy to find the UIPageViewController. But you might affect built-in behavior.


My problem is that I need the UIPageViewController to scroll vertically. The documentation (header file) says that its respects PDFView.displayDirection, but it does not. It's ALWAYS horizontal.

would appear as of beta 11.3 the default is vertical scroll and setting the ,displayDirection to either .vertical or .horizontal now works. Only you have to set these properties before you set the pdfViews document.


            pdfView!.translatesAutoresizingMaskIntoConstraints = false
            pdfView!.autoScales                                = true
            pdfView!.usePageViewController(true, withViewOptions: [:])
            pdfView!.displayDirection                          = .horizontal
            pdfView!.document                                  = PDFDocument(url: url)