ios - 在 PDFKit 中隐藏指示器滚动
问题描述
这是我的 PDFView 配置。我想用水平滚动显示 PDF 查看器,显示单页。
但是 PDFView 显示滚动指示器,这是不正确的。我想隐藏滚动指示器。我的问题是如何隐藏它或如何使其滚动位置正确?
pdfView.autoScales = true
pdfView.displaysPageBreaks = true
pdfView.displayMode = .singlePageContinuous
pdfView.usePageViewController(true)
pdfView.displayDirection = .horizontal
pdfView.minScaleFactor = 1
pdfView.document = pdfDocument
解决方案
由于 PDFview 无法访问其滚动元素,因此访问 pdfview 子视图的技巧可能对您有用。
在控制台上打印时的子视图链如下所示:
(lldb) po pdfView.subviews
▿ 1 element
- 0 : <_UIPageViewControllerContentView: 0x7fec7411d9f0; frame = (0 0; 414 808); clipsToBounds = YES; opaque = NO; autoresize = W+H; layer = <CALayer: 0x600001b33720>>
(lldb) po pdfView.subviews.first?.subviews.first
▿ Optional<UIView>
- some : <_UIQueuingScrollView: 0x7fec7483aa00; frame = (0 0; 414 736); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x6000015153e0>; layer = <CALayer: 0x600001b33740>; contentOffset: {414, 0}; contentSize: {1242, 736}; adjustedContentInset: {0, 0, 0, 0}>
(lldb)
所以基于此,我测试了下面的代码,它在我的最后工作。尝试使用代码:
let pdfScrollView = pdfView.subviews.first?.subviews.first as? UIScrollView
pdfScrollView?.showsHorizontalScrollIndicator = false // if pdf view scroll direction is horizontal
pdfScrollView?.showsVerticalScrollIndicator = false // if pdf view scroll direction is vertical
推荐阅读
- javascript - 客户端的 SEO 友好 url
- javascript - 使用 javascript 显示/隐藏项目
- java - 在没有时间和使用 jodatime 的情况下检查 java 中的日期范围
- java - 无法在 Loadrunner 中执行 Kafka 生产者代码
- firebase - Firebase / FCM 推送消息 - 主题和令牌清理
- cors - 如何从任何设备访问具有 CORS 和基本身份验证的远程 couchdb?
- java - 获取所需文件夹的路径及其内容
- php - 新记录未注册但仍显示新记录添加成功
- google-cloud-platform - 如何在 GCP Console(AppEngine 灵活环境)中查看已部署的源文件?
- typescript - 如何通过 Firebase 云功能部署服务器