2

I try to get notifications as soon as the currently visible pages in my pdfView change.

Actually this should work according to the documentation via .PDFViewVisiblePagesChanged.

However, I only get a notification the very first time when the pdfView didLoad.

As soon as I then scroll (and thus the visible pages change) I do not receive a single notification. The funny thing is that the notification .PDFViewPageChanged works normally (but in this case it is not enough). The same behaviour is also with .PDFViewScaleChanged: here I never get a notification when zooming inside the pdfView.

Code Snippet from my ViewController:

ovverride func viewDidLoad() {
    //...
    NotificationCenter.default.addObserver(self, selector: #selector(onDidVisiblePagesChanged(_:)), name: .PDFViewPageChanged, object: nil)
    //...
}
@objc func onDidVisiblePagesChanged(notification:Notification) {
   print("visible Pages changed!")
}
Axel Guilmin
  • 11,454
  • 9
  • 54
  • 64
Phil
  • 107
  • 1
  • 7
  • I have the same issue. I've reported it to bugreport.apple.com. It might be also documentation issue as well. – somedev Feb 21 '20 at 13:01

1 Answers1

-1

The problem is located in your function "onDidVisiblePagesChanged, you're waiting for a parameter type notification, you need to cast the parameter inside your function

@objc func onDidVisiblePagesChanged(_ sender:Any) {
    if let notification = sender as? Notification {
        print("visible Pages changed!")
        print(notification)
    }
}