在 PDFKit 中隐藏指示器滚动

时间:2021-04-20 03:09:43

标签: ios swift pdfkit

这是我的 PDFView 配置。我想用水平滚动显示 PDF 查看器,显示单页。

但 PDFView 显示滚动指示器,它不正确。我想隐藏滚动指示器。我的问题是如何隐藏它或如何使其滚动位置正确?

Horizontal scroll indicator visible at bottom of screen
pdfView.autoScales = true
pdfView.displaysPageBreaks = true
pdfView.displayMode = .singlePageContinuous
pdfView.usePageViewController(true)
pdfView.displayDirection = .horizontal
pdfView.minScaleFactor = 1
pdfView.document = pdfDocument

1 个答案:

答案 0 :(得分:1)

由于 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
相关问题