Objective c 已在PDFView中移动注释,但它会向相反方向移动

Objective c 已在PDFView中移动注释,但它会向相反方向移动,objective-c,xcode,macos,pdf,pdfview,Objective C,Xcode,Macos,Pdf,Pdfview,我已经编写了在拖动鼠标时移动注释的代码,但是结果显示注释移动到了鼠标移动轨迹的相反方向。它在鼠标第一个点击点的中心移动,中心对称相对。。。我为注释的边界绘制了一个矩形,但矩形位置是正确的 有两张图片向您展示了发生的情况: -在拖动之前: 我搬家后: 注释消失了 下面是我的代码: - (void) mouseDragged: (NSEvent *) theEvent { // Move annotation.

我已经编写了在拖动鼠标时移动注释的代码,但是结果显示注释移动到了鼠标移动轨迹的相反方向。它在鼠标第一个点击点的中心移动,中心对称相对。。。我为注释的边界绘制了一个矩形,但矩形位置是正确的

有两张图片向您展示了发生的情况:

-在拖动之前:

  • 我搬家后:

注释消失了

下面是我的代码:

- (void) mouseDragged: (NSEvent *) theEvent
{


                    // Move annotation.
                    // Hit test, is mouse still within page bounds?
                    if (NSPointInRect([self convertPoint: mouseLoc toPage: activePage],
                                      [[_activeAnnotation page] boundsForBox: [self displayBox]]))
                    {
                        // Calculate new bounds for annotation.
                        newBounds = currentBounds;
                        newBounds.origin.x = roundf(endPt.x - _clickDelta.x);
                        newBounds.origin.y = roundf(endPt.y - _clickDelta.y);
                    }
                    else
                    {
                        // Snap back to initial location.

                        newBounds = _wasBounds;
                    }
// Change annotation's location.
            [_activeAnnotation setBounds: newBounds];

            // Call our method to handle updating annotation geometry.
            [self annotationChanged];

            // Force redraw.
            dirtyRect = NSUnionRect(currentBounds, newBounds);
            dirtyRect.origin.x -= 10;
            dirtyRect.origin.y -= 10;
            dirtyRect.size.width += 20;
            dirtyRect.size.height += 20;
              [super setNeedsDisplay:YES];
            [self setNeedsDisplayInRect:RectPlusScale([self convertRect: dirtyRect fromPage: [_activeAnnotation page]], [self scaleFactor])];

 [super mouseDragged: theEvent];
奇怪的是,如果注释是一个图像或文本,那么被移动的内容是正确的。它仅在PDFanNotationLink类中发生