-1

无法在 ios 10 中创建水平滚动 PDF 视图。这在 iOS 11 中是否可行?使用 PDFKit - PDFView ?

4

2 回答 2

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)
于 2017-09-29T15:55:57.590 回答
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    
            }
        }
于 2018-05-20T05:08:44.390 回答