Codes are not working at this video.

https://developer.apple.com/videos/play/wwdc2022/10089/

I am trying to run codes about PDFPageOverlayViewProvider, but the codes are not working. I cannot see what I wrote or annotate. Anyone know how can I solve and make this code working?

 func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? {

        var resultView: PKCanvasView? = nil

        if let overlayView = pageToViewMapping[page] {
            resultView = (overlayView as! PKCanvasView)
        } else {

            let canvasView = PKCanvasView(frame: .zero)
            canvasView.drawingPolicy = .anyInput
            canvasView.tool = PKInkingTool(.pen, color: .yellow, width: 20)
            canvasView.backgroundColor = .clear
            pageToViewMapping[page] = canvasView
            resultView = canvasView
        }

        let page = page as! WatermarkPage
        if let drawing = page.drawing {
            resultView?.drawing = drawing
        }

        return resultView

    }

    

    func pdfView(_ pdfView: PDFView, willEndDisplayingOverlayView overlayView: UIView, for page: PDFPage) {
        let overlayView = overlayView as! PKCanvasView
        let page = page as! WatermarkPage
        page.drawing = overlayView.drawing
        pageToViewMapping.removeValue(forKey: page)

    }

Hi, in my case the overlayView(For:) method is called when I create and display my editing view controller. The issue I have is the willEndDisplayingOverlayView never gets called and when the contents(forType:) is running on the UIDocument I'm saving, it never gets th custom PDFPages drawing content, so I get no data. (althrought the PDFDocumentDelegate is set). Sorry, I'm 5 months late, but : Did you manage to do something ?

Hello, did you manage to find out the sample code ? Or did you figure out how to achieve the functionality on your own ?

Codes are not working at this video.
 
 
Q