以编程方式将NSScrollView滚动到左上角

时间:2013-08-12 12:49:01

标签: objective-c macos cocoa

嗯,这就是我想要做的但到目前为止没有成功。

这就是我的尝试:

- (void)awakeFromNib
{
    [[_myScrollView contentView] scrollToPoint:NSMakePoint(0,[[_myScrollView contentView] bounds].size.height)];
}

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

怎么样:

[[_myScrollView contentView] scrollToPoint:NSMakePoint(0,0)];

答案 1 :(得分:0)

试试这个

NSPoint newScrollOrigin = NSMakePoint(0.0,NSMaxY([[_myScrollView documentView] frame])
                          -NSHeight([[_myScrollView contentView] bounds]));

[[_myScrollView documentView] scrollPoint:newScrollOrigin];

要了解更多信息,请参阅此链接 -

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/NSScrollViewGuide/Articles/Scrolling.html