无法在ios 10中创建水平滚动PDF视图。 在iOS 11中这可能吗?使用PDFKit - PDFView?
答案 0 :(得分:5)
您可以这样做:
//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)
答案 1 :(得分:0)
这对我有用:
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
}
}