Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect that a PDFView did scroll

Does PDFKit on iOS expose a PDFView's underlying UIScrollView or is there any other way to directly detect that the user has scrolled a PDFView?

My use case is to hide a nav bar when the document is scrolled so as a workaround I've added my own pan gesture recogniser to the PDFView's parent and I do the hiding in gestureRecognizerShouldBegin and always return false but I expect there's something more like UIScrollViewDelegate that I'm missing in the docs.

like image 521
Michael Behan Avatar asked Jan 10 '18 10:01

Michael Behan


1 Answers

Try this,

NotificationCenter.default.addObserver(self, selector: #selector(handlePageChange(notification:)), name: Notification.Name.PDFViewPageChanged, object: nil)

@objc private func handlePageChange(notification: Notification)
{
    print("Page changed")
}
like image 97
Manikandan D Avatar answered Oct 23 '22 10:10

Manikandan D