iosswiftquicklookqlpreviewcontroller

Is it possible to know when a QLPreviewController reaches the end of a document?


I use a QLPreviewController to display a pdf file to my users. Everything works well. I just want know when the user reach the end of the document.

Do you know if it's possible ?

Thanks you.


Solution

  • Unfortunately it's not, the main issue is there is no nice/clean way to figure out if the scroll position has reached the end of the document. I've tried going through all the controller's subviews to find the UIScrollView instance so I could set it's delegate to my subclassed instance of QLPreviewController but it doesn't have one, seems it uses some other UI element to handle the scrolling that is pretty locked down.

    You are better off just using the QLPreviewControllerDelegate and making use of the func previewControllerWillDismiss(_ controller: QLPreviewController) function to detect when the user is finished previewing the document instead of reaching the bottom.