Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSScrollView jumping to bottom on scroll

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)];
like image 792
Nick Locking Avatar asked Dec 22 '10 05:12

Nick Locking


1 Answers

My hacky solution. Turn on Show Vertical Scroller (like Chetan said, this is what triggers the bug). Send table view to back. Expand left edge of table view until the scroller is covered by whatever's to the right edge of it.

like image 177
overcyn Avatar answered Sep 25 '22 07:09

overcyn