ios PDFKit displaymode = singlepage仅显示pdf的第一页 [英] ios PDFKit displaymode = singlepage only shows the first page of the pdf

查看:497
本文介绍了ios PDFKit displaymode = singlepage仅显示pdf的第一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过苹果的PDFKit库在ios上显示pdf,而不是使用PDFDisplayMode.singlePageContinuous模式,而是想在分页符处停止,所以我尝试使用PDFDisplayMode.singlePage. https://developer.apple.com/documentation/pdfkit/pdfdisplaymode

I'm trying to display a pdf on ios via apples PDFKit library, and rather than use PDFDisplayMode.singlePageContinuous mode, I want to stop at page breaks so I'm trying to use PDFDisplayMode.singlePage. https://developer.apple.com/documentation/pdfkit/pdfdisplaymode

但是,此模式似乎仅显示pdf的一页,这是完全没有用的.我试过在页面上添加滑动处理程序,但是它们都不起作用.

However, this mode seems to only display one page of the pdf which is quite useless. I've tried adding swipe handlers to the page but they aren't working either.

我找到了示例应用程序,并更改了其代码以测试pdfdisplaymode,但遇到了相同的问题,例如 https://github.com/vipulshah2010/PDFKitDemo

I've found sample applications and altered their code to test the pdfdisplaymode but get the same problem e.g. https://github.com/vipulshah2010/PDFKitDemo

如何使用pdfkit一次实现pdfviewer的一页,从而允许在页面之间滑动?

How can I implement a one page at a time pdfviewer with pdfkit, that allows swiping between pages?!

推荐答案

另一种简单的方法是设置

A another simple way to do this is setting

pdfView.usePageViewController(true) 

这将为您添加页面之间的滑动,而无需设置自己的手势.参见下面的示例:

This adds the swiping between pages for you and no need to set up your own gestures. See example below:

override func viewDidLoad() {
    super.viewDidLoad()

    // Add PDFView to view controller.
    let pdfView = PDFView(frame: self.view.bounds)
    self.view.addSubview(pdfView)

    // Configure PDFView to be one page at a time swiping horizontally
    pdfView.autoScales = true
    pdfView.displayMode = .singlePage
    pdfView.displayDirection = .horizontal
    pdfView.usePageViewController(true)

    // load PDF
    let webUrl: URL! = URL(string: url)
    pdfView.document = PDFDocument(url: webUrl!)
}

这篇关于ios PDFKit displaymode = singlepage仅显示pdf的第一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆