PDFView - 适合 2 页的高度和宽度启用滚动到下一页
我有一个视图,其中包含来自 PDFKit
的 PDFView
。我想在屏幕上同时看到 2 个完整页面,并且它们需要适合高度和宽度。我可以看到两种方法,但都不是完美的:
选项 1)使用 .twoUpContinously
显示模式 - 这里它适合宽度,但高度在 PDF 的约 2/3 中被裁剪。
lazy var pdfView: PDFView = {
let view = PDFView().layoutable()
view.displayMode = .twoUpContinuous // !
view.displayDirection = .vertical
view.minScaleFactor = view.scaleFactorForSizeToFit
view.maxScaleFactor = 3
view.autoScales = true
return view
}()
选项 2)使用 .twoUp
显示模式 - 这里它适合宽度和高度,但手势识别器不会记录向下滑动,因此用户无法将页面更改为 3 和 4。
lazy var pdfView: PDFView = {
let view = PDFView().layoutable()
view.displayMode = .twoUp // !
view.displayDirection = .vertical
view.minScaleFactor = view.scaleFactorForSizeToFit
view.maxScaleFactor = 3
view.autoScales = true
return view
}()
是否有内置的- 这种情况的解决方案..?或者我是否必须添加手动滑动手势识别器并基于 .twoUp
解决方案更改页面..?
I have a view, which contains PDFView
from PDFKit
. I want to see 2 full pages at once on my screen and they need to fit both height and width. I can see 2 ways of doing it, but neither is perfect:
Option 1) Display mode with .twoUpContinuous
- here it fits width, but height is cropped in ~2/3 of the PDF.
lazy var pdfView: PDFView = {
let view = PDFView().layoutable()
view.displayMode = .twoUpContinuous // !
view.displayDirection = .vertical
view.minScaleFactor = view.scaleFactorForSizeToFit
view.maxScaleFactor = 3
view.autoScales = true
return view
}()
Option 2) Display mode with .twoUp
- here it fits width and height, but gesture recognizer doesn't record swipe down, and as a result user cannot change page to 3 and 4.
lazy var pdfView: PDFView = {
let view = PDFView().layoutable()
view.displayMode = .twoUp // !
view.displayDirection = .vertical
view.minScaleFactor = view.scaleFactorForSizeToFit
view.maxScaleFactor = 3
view.autoScales = true
return view
}()
Is there any built-in solution for such case..? Or do I have to add manually swipe gesture recognizer and change pages based on that with .twoUp
solution..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以最后我想到了3个解决方案,但都不是完美的。我最喜欢解决方案3。
解决方案 1:不稳定,有时无法渲染 pdf 或启动时不在第一页。但大多数情况下工作正常。
解决方案2:水平方向完美,垂直方向则不然。适合 2 个 PDF 的宽度,但底部被裁剪。对于 A4 文档,在大多数 iPad 上不应裁剪太多,因为它们的宽高比均为 3:4。
解决方案 3:当您用手指滚动到 PDF 内的下一页/上一页时,没有动画。
So in the end I thought of 3 solutions, neither of them is perfect. I like solution 3 the most.
SOLUTION 1: not stable, is failing to render pdf from time to time or launches not on the 1st page. But most often works fine.
SOLUTION 2: horizontally perfect, vertically not. Width of 2 PDFs fits, however the bottom is cropped. In case of A4 documents, that should crop not too much on most iPads, because all of them have the aspect ratio of 3:4.
SOLUTION 3: There is no animation when you scroll with your finger to the next/previous page INSIDE PDF.