Whenever the current page changes by scrolling the pdf view in PDFkit, apps can detect the change adding the observer with PDFViewPageChanged.
The related sample code is as below,
// Add page change observer
NotificationCenter.default.addObserver(self,
selector: #selector(pageDidChange(notification:)),
name: Notification.Name.PDFViewPageChanged,
object: nil)
@objc private func pageDidChange(notification: Notification) {
// pdfView is of type PDFView
let currentPageNumber = pdfView.document?.index(for: pdfView.currentPage!)
}
From How to know when user swipes to next page in PDFView of PDFKit?
PDFViewPageChanged works well in iOS 15.0 and before. However, in case of iOS 15.2 and 15.4 (or later, latest)a function bound to PDFViewPageChanged is not called when the page changes.
I googled tons of pages to solve it. I couldn't find any solution or hints. Please help me. It's a very essential and fundamental function. So it's very strange.