但是,除非我放大或缩小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来绘制一条线.
从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上不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)