PDFView setNeedsDisplay:YES doesn't work on MacOS Sierra 10.12

前端 未结 1 506
挽巷
挽巷 2021-01-06 09:50

I have use [PDFView setNeedsDisplay:YES] to let the PDF view redraw, and it worked great on OSX 10.9-10.11. However it doesn\'t work unless I zoom in or zoom o

相关标签:
1条回答
  • 2021-01-06 10:11

    I'm having the same trouble. The first time I add an annotation, PDFView displays that annotation on the page immediately. From then on, adding or removing an annotation works fine in code but PDFView doesn't show the change until I manually scroll the view.

    From PDFKit I've tried:

    previewView.layoutDocumentView()
    
    for pageIndex in 0...pdf.pageCount - 1 {
      let page = pdf.page(at: pageIndex)!
      previewView.annotationsChanged(on: page)
    }
    

    and from NSView I've tried:

    previewView.needsDisplay = true
    previewView.needsLayout = true
    previewView.documentView?.needsDisplay = true
    previewView.updateLayer()
    

    but no luck. I've tried scrolling the PDFView with code too but it hasn't been a reliable way of sneaking a refresh, and in general shouldn't be the way to do this.

    0 讨论(0)
提交回复
热议问题