objective-c – PDFView setNeedsDisplay:YES在MacOS Sierra 10.12上不起作用

objective-c – PDFView setNeedsDisplay:YES在MacOS Sierra 10.12上不起作用,第1张

概述我使用[PDFView setNeedsDisplay:YES]让PDF视图重绘,它在OSX 10.9-10.11上运行良好. 但是,除非我放大或缩小PDF页面,否则它不起作用… 还有其他方法可以立即重绘吗?代码如下: NSRect newBounds;NSRect currentBounds;NSRect dirtyRect;NSPoint mouse 我使用[pdfVIEw setNeedsdisplay:YES]让pdf视图重绘,它在OSX 10.9-10.11上运行良好.
但是,除非我放大或缩小pdf页面,否则它不起作用…

还有其他方法可以立即重绘吗?代码如下:

NSRect      newBounds;NSRect      currentBounds;NSRect      dirtyRect;NSPoint     mouseLoc;NSPoint     endPt;// Where is annotation Now?currentBounds = [_activeAnnotation bounds];// Mouse in display vIEw coordinates.mouseLoc = [self convertPoint: [theEvent locationInWindow] fromVIEw: NulL];// Convert end point to page space.if(activePage == nil)    activePage =[_activeAnnotation page];_linePoint= [self convertPoint: mouseLoc topage: activePage];endPt = [self convertPoint: mouseLoc topage: activePage];if(_selectedIDx == 3) //ink{    [(pdfAnnotationInk*)_activeAnnotation removeBezIErPath:_path];    //endPt.x=_xPoint.x; //竖线    //endPt.y=_xPoint.y; //横线    [_path linetoPoint:endPt];  //  普通笔    [(pdfAnnotationInk*)_activeAnnotation addBezIErPath:_path];    [self annotationChanged];    [self setNeedsdisplay:YES];    return;

更新:

我发现setNeedsdispaly调用drawPage:toContext:但是绘图代码在drawPage:toContext中不起作用:

- (voID)drawPage:(pdfpage *)pdfpage toContext(CGContextRef)context{    [super drawPage: pdfpage toContext:context];    NSBezIErPath *line=[NSBezIErPath bezIErPath];    [line movetoPoint:_xPoint];    [line linetoPoint:NSMakePoint(150,150)];    [[NScolor redcolor] set];    [line setlinewidth:50] ;    [line stroke];}

调试说CGContextSetFillcolorWithcolor:无效的上下文0x0和更多无效的上下文0x0警告.
我在drawPage中做了什么:toContext:正在测试并且只是使用BezIErPath来绘制一条线.

解决方法 我遇到了同样的麻烦.我第一次添加注释时,pdfVIEw会立即在页面上显示该注释.从那时起,添加或删除注释在代码中工作正常但pdfVIEw在我手动滚动视图之前不会显示更改.

从pdfKit我尝试过:

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

从NSVIEw我尝试过:

prevIEwVIEw.needsdisplay = trueprevIEwVIEw.needsLayout = trueprevIEwVIEw.documentVIEw?.needsdisplay = trueprevIEwVIEw.updateLayer()

但没有运气.我已尝试用代码滚动pdfVIEw,但它不是一种可靠的方式来偷偷摸摸,并且通常不应该是这样做的方法.

总结

以上是内存溢出为你收集整理的objective-c – PDFView setNeedsDisplay:YES在MacOS Sierra 10.12上不起作用全部内容,希望文章能够帮你解决objective-c – PDFView setNeedsDisplay:YES在MacOS Sierra 10.12上不起作用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1003441.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存