0

我在 nsScrollView 内的图像上得到一个点。它可能在图像内的任何位置。我想计算要滚动到的新点?我怎样才能做到这一点?

图像位于滚动视图内的图像视图内。

[NSAnimationContext beginGrouping];
    [[NSAnimationContext currentContext] setDuration:2.0];
    NSClipView* clipView = [self.scrollView contentView];
    NSPoint newOrigin = [clipView bounds].origin;

     newOrigin.x = ?
    newOrigin.y = ?

    [[clipView animator] setBoundsOrigin:newOrigin];
    [NSAnimationContext endGrouping];
4

1 回答 1

0

尝试这个

- (void)mouseMoved:(NSEvent *)theEvent
{
    NSPoint event_location = [theEvent locationInWindow];
    _mousepos = [self convertPoint:event_location fromView:nil];
    ...
}

它实际上取自文档。

于 2013-11-19T18:54:49.020 回答