0
votes

OK, this thing has been bugging me for quite some time.

I've got an NSScrollView (X= 258, Y= 322, W=516, H=653) with a view in it (X= -283, Y= -215, W= 1800 H= 1800), and I'm desperately trying to make it scroll to the top-left corner.

I've tried [[_previewScrollView contentView] scrollToPoint:NSMakePoint(0,0)]; but it didn't help.

Any ideas?

2

2 Answers

0
votes

The put the inner view at X = 0, Y = 0, or do a scrollToPoint:NSMakePoint(-283, -215). The subview needs a relative coordinate.

Also, are you sure your IBOutlet to scrollview is not nil?

-1
votes

Try setting the correct contentSize

[_previewScrollView.documentView setFrame: NSMakeRect(0,0,1800, 1800)];

The code I use to scroll to top:

[_previewScrollView.contentView scrollToPoint:NSMakePoint(0, ((NSView*)_previewScrollView.documentView).frame.size.height - _previewScrollView.contentSize.height)];