【发布时间】:2017-09-27 18:20:40
【问题描述】:
无法在 ios 10 中创建水平滚动 PDF 视图。 这在 iOS 11 中可行吗?使用 PDFKit - PDFView ?
【问题讨论】:
-
这个 Q 超出了 SO 的范围。报告您迄今为止所做的尝试,并在必要时询问具体问题。
标签: objective-c swift ios11 pdfkit pdfview
无法在 ios 10 中创建水平滚动 PDF 视图。 这在 iOS 11 中可行吗?使用 PDFKit - PDFView ?
【问题讨论】:
标签: objective-c swift ios11 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
}
}
【讨论】: