无法在iOS 10中创建水平滚动PDF视图。这在iOS 11中是否可以?使用PDFKIT -PDFVIEW?
您可以做这样的事情:
//configure the pdfView or use it from an outlet in Storyboard
let pdfView = PDFView(frame: self.view.bounds)
let url = Bundle.main.url(forResource: "pdfFile", withExtension: "pdf")
pdfView.document = PDFDocument(url: url!)
//the important setting
pdfView.displayDirection = .horizontal
pdfView.usePageViewController(true, withViewOptions: nil)
//add to subview if you don't use an outlet
self.view.addSubview(pdfView)
这对我有用:
if let path = Bundle.main.path(forResource: "myfile", ofType: "pdf") {
let url = URL(fileURLWithPath: path)
if let pdfDocument = PDFDocument(url: url) {
pdfView.autoScales = true
pdfView.displayMode = .singlePage
pdfView.displayDirection = .horizontal
pdfView.usePageViewController(true, withViewOptions: [UIPageViewControllerOptionInterPageSpacingKey: 5])
pdfView.document = pdfDocument
}
}