NSScrollView jumping to bottom on scroll
- by Nick Locking
I have an NSScrollView containing an NSImageView, which resizes based on various factors. When it resizes I have generally changed the image, so I scroll the NSScrollView to the top. This works fine. However, when I start to scroll the NSScrollView again, it moves a few pixels and then (most of the time) jumps to the bottom of the scroll. After it jumps once, it works as normal until I move the scroller to the top again. This is driving me insane. All I'm really doing is this:
[_imageView setImage: anNSImage];
NSRect frame;
NSSize imageSize = [anNSImage] size];
frame.size = imageSize;
frame.origin = NSZeroPoint;
[_imageView setFrame: frame];
[[_mainScrollview contentView] scrollToPoint: NSMakePoint(0, [_imageView frame].size.height - [_mainScrollview frame].size.height)];