0

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?

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223

2 Answers2

0

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?

Rob van der Veer
  • 1,148
  • 1
  • 7
  • 20
  • Hmmm... Sorry, this did nothing at all. – Dr.Kameleon Aug 15 '13 at 08:02
  • 1
    Well if 'nothing helps', and 'it didn't work' is all you come up with, you're on your own. – Rob van der Veer Aug 15 '13 at 09:01
  • Don't get me wrong. I know my comments may not seem that... "helpful". However, I still do not know what to say, since I'm getting zero error messages. And I most definitely cannot describe what the suggestions' result is. Yours did nothing at all - no effect whatsoever. While @RolandKeesom 's suggestion *did* move the scrollview content, but I still can't understand *how* it moved it... :S – Dr.Kameleon Aug 15 '13 at 10:02
  • As for the `IBOutlet` to the scrollView not being `nil`, it's already been perfectly `NSLog`ged - so that's not the issue... – Dr.Kameleon Aug 15 '13 at 10:04
  • Can you get this tutorial working? http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content – Rob van der Veer Aug 15 '13 at 16:55
-1

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)];
Roland Keesom
  • 8,180
  • 5
  • 45
  • 52