I'm trying to display a pdf using the built in usePageViewController
method but it is crashing when I use it. I don't see others having this issue and they seem to implement it similar to me. Here's how I'm doing it:
guard let path = Bundle.main.url(forResource: "ReadMe", withExtension: "pdf") else { return }
if let document = PDFDocument(url: path)
{
pdfView.document = document
pdfView.autoScales = true
pdfView.displayDirection = .horizontal
pdfView.usePageViewController(true, withViewOptions: nil)
}
The error I get when it crashes is this:
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
I've tried moving around the items in the if statement and when I put usePageViewController
before setting the document it crashes when I set the document and when I call that method after setting the document it crashes on that method call.
pdfView.usePageViewController(true, withViewOptions: nil)
pdfView.document = document
// ^^^ Crashes Here ^^^
pdfView.document = document
pdfView.usePageViewController(true, withViewOptions: nil)
// ^^^ Crashes Here ^^^
I'm just trying to test to see if using this method will work for the pdf I'm using instead of doing it by hand. Please let me know if you have any idea on what I'm doing wrong here, thanks!