我认为这是PDFView中的一个错误.
作为解决方法,我建议手动滚动顶部:
self.pdfView.document = pdfDocument;
NSPoint pt = NSMakePoint(0.0, [self.pdfView.documentView bounds].size.height);
[self.pdfView.documentView scrollPoint:pt];
Run Code Online (Sandbox Code Playgroud)
rdar:// 37942090:PDFview在单页文档中滚动到页面底部.
这就是我所做的,它有点hacky
if let scrollView = pdfView.subviews.first as? UIScrollView {
scrollView.contentOffset.y = 0.0
}
Run Code Online (Sandbox Code Playgroud)
小智 6
我提出了这个滚动到第一页顶部的解决方案(它适用于 iOS 11.3):
if let document = pdfView.document,
let firstPage = document.page(at: 0)
{
let firstPageBounds = firstPage.bounds(for: pdfView.displayBox)
pdfView.go(to: CGRect(x: 0, y: firstPageBounds.height, width: 1.0, height: 1.0), on: firstPage)
}
Run Code Online (Sandbox Code Playgroud)
小智 6
看起来该go命令需要在下次运行循环时执行才能可靠地工作:
DispatchQueue.main.async
{
guard let firstPage = pdfView.document?.page(at: 0) else { return }
pdfView.go(to: CGRect(x: 0, y: Int.max, width: 0, height: 0), on: firstPage)
}
Run Code Online (Sandbox Code Playgroud)
在 iOS 12 上测试
| 归档时间: |
|
| 查看次数: |
2701 次 |
| 最近记录: |