PDFKit: Displaying PDFs | raywenderlich.com

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/2910256-pdfkit-displaying-pdfs

Sorry but the phrase “almost impossible” is not so accurate. I personally manage to present PDFs to many enterprise apps in iOS without PDFKit and with very easy way. Isn’t impossible or hard to present PDF or attachments but the PDFKit has many features specific for PDF for the presentation that has more advanced usages (like thumbnails etc.).

Hi Rony!
I tried to recreate a simple pdf displaying app based on your screencast but I got this error:
Terminating app due to uncaught exception ‘CALayerInvalidGeometry’, reason: ‘CALayer position contains NaN: [nan nan]’
Do you have any idea why?

Sounds like you’re experiencing a problem with placing one of your views on screen. Try looking at the stack trace, which should refer you to the exact line that causes the error. This may even be as simple to fix as specifying the desired position with a float instead of an int.
Also, try downloading the sample project and making sure it’s running as expected on your device. If so, you can try comparing that code to yours.

I hope this helps and good luck! :]

dont have the speed set so fast next time please

Hi Rony,
I have a question about PDFView, maybe you can help:

The 0th subview of a pdfView instance is a special scrollview (private PDFScrollView).
I want to synchronise my own scrollview with this pdfscrollview, so that when I scroll and zoom the pdfscrollView with gestures, then my own scrollview scrolls and zooms in exactly the same way.
Unfortunately, one does not have access to the scrollview delegate of pdfscrollview (which is also pdfscrollview) and hence no access to its scrollview delegate callback functions like scrollViewDidScroll etc. I could reassign the delegate to my own viewController (eg pdfscrollview.delegate = myVC) and thus have myVC implement the callback methods instead (it even seems to work), but this seems to me a bit dangerous from a stability perspective. Would you have a tip about how I can achieve the same outcome (eg. synchronising my own scrollview with the pdfscrollView) in a safe or best practice way?

Thank you very much for your help!

@ronyr Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hey Celine and sorry for the late response,
What you’re describing really does sound a bit risky, but unfortunately I can’t think of a better way off the top of my head. Did you end up going in the direction you described or finding another way?

Thank you for the feedback Rony! I am not too comfortable to go in that direction, and I am still wondering around a bit before I will decide what I will do. :slight_smile: