How do I correctly show a PDF document?
iPad and Xcode 15.4
Within my GameViewController
, I have:
func presentScene(_ theScene: SKScene) {
theScene.scaleMode = .resizeFill
if let skView = self.view as? SKView {
skView.ignoresSiblingOrder = true
skView.showsFPS = true
skView.showsNodeCount = true
#if os(iOS)
let theTransition = SKTransition.doorway(withDuration: 2.0)
skView.presentScene(theScene, transition: theTransition)
#elseif os(tvOS)
skView.presentScene(theScene)
#endif
}
} // presentScene
I believe presentScene(theScene)
goes to the sceneDidLoad() func
of theScene
which adds various SKSpriteNodes
to the scene via a call to addChild(theNode)
.
So far so good ...
Until I have a SKScene
wherein I wish to display a PDF.
I use this snippet to display this PDF with this call within the SKScene's sceneDisLoad()
:
displayPDF("ABOUT_OLD_WEST_LOCOMOTIVE")
func displayPDF(_ itsName:String) {
let pdfView = PDFView()
guard let path = Bundle.main.path(forResource: itsName, ofType: "pdf")
else { return }
print("path")
guard let pdfDocument = PDFDocument(url: URL(fileURLWithPath: path))
else { return }
print("pdfDocument")
pdfView.displayMode = .singlePageContinuous
pdfView.autoScales = true
pdfView.displayDirection = .vertical
pdfView.document = pdfDocument
} // displayPDF
The 2 print
statements show, yet the SKScene
does not display the PDF via pdfView.document = pdfDocument
?
Anyone have a clue what errors I have committed?
Appreciate it.