NSScrollView jumping to bottom on scroll
Posted
by
Nick Locking
on Stack Overflow
See other posts from Stack Overflow
or by Nick Locking
Published on 2010-12-22T05:19:05Z
Indexed on
2010/12/22
8:54 UTC
Read the original article
Hit count: 364
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)];
© Stack Overflow or respective owner