【问题标题】:How to create horizontal scrolling PDF view using PDFKit iOS 11如何使用 PDFKit iOS 11 创建水平滚动 PDF 视图
【发布时间】:2017-09-27 18:20:40
【问题描述】:

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

【问题讨论】:

  • 这个 Q 超出了 SO 的范围。报告您迄今为止所做的尝试,并在必要时询问具体问题。

标签: objective-c swift ios11 pdfkit pdfview


【解决方案1】:

你可以这样做:

//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)

【讨论】:

  • 嗨!设置文档后添加 displayDirection 不起作用!但是我试图在 addSubview 之前设置 pdfDocument 并且正在工作!我希望你在粘贴之前已经测试了上面的代码!
  • @SaurabhPrajapati 是的,我已经像往常一样在发布到 stackoverflow 之前进行了测试。
  • 对不起我的旧评论,但它对我不起作用
【解决方案2】:

这对我有用:

        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    
            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-09
    • 2011-09-29
    • 1970-01-01
    • 2015-12-20
    • 1970-01-01
    • 2015-03-06
    • 1970-01-01
    相关资源
    最近更新 更多