I am using an IKImageBrowserView to show a grid of images. I do not have any code that sets points or offsets or scrolls anything programmatically. I simply have code that lists the contents of a directory full of images and displays them in the image browser.
Upon launching the application, the scrolling view scrolls to the bottom of the grid of images, unprovoked. For a few seconds after this, if you try to scroll up with the mouse, the scroller glitches out and still try to scroll to the bottom. Thereafter, the issue stops and the user can scroll normally.
Prior to El Capitan, the auto-scroll was not happening.
Again, there is no code that scrolls the NSSrcollView or set the contentOffset, or scrollToRect, scrollToVisibleRect.
With that said, I have tried setting these values after the images have loaded with no success.
Question 1: Has anyone experienced this with NSScrollView or IKImageBrowserView on El Capitan (or possibly any Mac OS version)?
Question 2: Is there any way to debug why this is happening or how to get this to stop scrolling automatically?
This solution ended up working for me. Be sure to connect your outlets correctly.
@interface WCSScrollView : NSScrollView
@end
@class IKImageBrowserView;
@interface WCSScrollView ()
@property (strong) IBOutlet NSClipView * scrollerClipView;
@property (strong) IBOutlet IKImageBrowserView * imageBrowser;
@end
@implementation WCSScrollView
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
}
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
NSClipView * clip = self.subviews[0];
self.imageBrowser = (IKImageBrowserView*)clip.subviews[0];
}
@end

You need to subclass the NSScrollView
.h
#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
// This class fixes a glitch with the
// ikimagebrowserview
// http://stackoverflow.com/questions/33643289/cocoa-nsscrollview-with-ikimagebrowserview-scrolls-to-bottom
@interface IKImageBrowserScrollFixScrollView : NSScrollView
@end
.m
#import "IKImageBrowserScrollFixScrollView.h"
@implementation IKImageBrowserScrollFixScrollView
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
NSClipView * clipView;
for (NSView * v in self.subviews) {
if ([v isKindOfClass:[NSClipView class]]) {
clipView = (NSClipView *)v;
break;
}
}
IKImageBrowserView * imageBrowser;
for (NSView * v in clipView.subviews) {
if ([v isKindOfClass:[IKImageBrowserView class]]) {
imageBrowser = (IKImageBrowserView *)v;
break;
}
}
NSRect r = imageBrowser.frame;
[super resizeSubviewsWithOldSize:oldSize];
imageBrowser.frame = r;
}
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With