I am trying to make a vertical scrolling PDFView using the following code:
pdfView = PDFView(frame: view.frame)
pdfView.backgroundColor = UIColor.white
var documentName: String = "test"
if let documentURL = Bundle.main.url(forResource: documentName, withExtension: "pdf") {
if let document = PDFDocument(url: documentURL) {
pdfView.displayDirection = .vertical
pdfView.usePageViewController(true, withViewOptions: nil)
pdfView.document = document
}
}
self.view.addSubview(pdfView)
It displays fine, but the displayDirection is horizontal, not vertical. I'm trying to find a way to set the withViewOptions, but I can't find relevant info on this.
I checked on SO, and many people suggest to add displayDirection
but that doesn't see to change anything.
On the other hand, when I try to run the following code:
pdfView = PDFView(frame: view.frame)
pdfView.backgroundColor = UIColor.white
var documentName: String = "test"
if let documentURL = Bundle.main.url(forResource: documentName, withExtension: "pdf") {
if let document = PDFDocument(url: documentURL) {
pdfView.autoScales = true
pdfView.displayDirection = .vertical
pdfView.displayMode = .singlePage
pdfView.document = document
}
}
self.view.addSubview(pdfView)
It just displays the first page and it doesn't scroll. I need to add swipe gestures recognizers and the scroll is not smooth. Beside, it seems overkill for a single page scrolling functionality...
Am I missing something? Any help would be greatly appreciated!