8

in my mac application pdfkit using for pdf reader.while scroll the mouse scroll the pages changing how can avoid that.pdfview's display mode is kPDFDisplaySinglePage.No need to work scroll Please help me

SHEBIN
  • 163
  • 1
  • 10

3 Answers3

9

Hacky, brittle and a year or two too late, but... the first subview of your PDFView is a private NS/UIScrollView-derived PDFScrollView. Simply cast this and change its isScrollEnabled property to false, e.g. for iOS:

(yourPdfView.subviews[0] as! UIScrollView).isScrollEnabled = false

Alternatively, and probably a better answer: turn off user interaction for the view, or otherwise intercept and handle it.

Robin Macharg
  • 1,468
  • 14
  • 22
1

If displayMode == .singlePage, then you can use this method:

// MARK: - Disable Scroll
extension PDFView {
    func disableScroll(_ isDisable: Bool) {
        if let scrollView = (self.subviews.first?.subviews.first as? UIScrollView) {
            scrollView.isScrollEnabled = !isDisable
        }
    }
}

Call like this:

yourPdfView.disableScroll(true)
M Afham
  • 834
  • 10
  • 15
0

Important notes:

Make sure you set displayMode to .singlePage and you are not using pdfView.usePageViewController(true)

pdfView.displayMode = .singlePage
(pdfView.subviews.first(where: { $0 is UIScrollView }) as? UIScrollView)?.isScrollEnabled = false
Arthur Stepanov
  • 511
  • 7
  • 4