我正在尝试使用以下代码制作垂直滚动 PDFView:
pdfView = PDFView(frame: view.frame)
pdfView.backgroundColor = UIColor.white
var documentName: String = "test"
if let documentURL = Bundle.main.url(forResource: documentName, withExtension: "pdf") {
if let document = PDFDocument(url: documentURL) {
pdfView.displayDirection = .vertical
pdfView.usePageViewController(true, withViewOptions: nil)
pdfView.document = document
}
}
self.view.addSubview(pdfView)
它显示良好,但 displayDirection 是水平的,而不是垂直的。我正在尝试找到一种方法来设置 withViewOptions,但是我找不到 https://stackoverflow.com/questions/46543946/key-values-for-usepageviewcontrollers-options与此相关的信息。
我查了一下,很多人建议添加displayDirection
但这并没有改变任何事情。
另一方面,当我尝试运行以下代码时:
pdfView = PDFView(frame: view.frame)
pdfView.backgroundColor = UIColor.white
var documentName: String = "test"
if let documentURL = Bundle.main.url(forResource: documentName, withExtension: "pdf") {
if let document = PDFDocument(url: documentURL) {
pdfView.autoScales = true
pdfView.displayDirection = .vertical
pdfView.displayMode = .singlePage
pdfView.document = document
}
}
self.view.addSubview(pdfView)
它只显示第一页并且不滚动。我需要添加滑动手势识别器,但滚动不平滑。此外,对于单页滚动功能来说似乎有点过分了......
我错过了什么吗?任何帮助将不胜感激!
Try pdfView.displayMode = .singlePageContinuous
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)