Skip to content

Instantly share code, notes, and snippets.

@hetima hetima/gist:5142318
Created Mar 12, 2013

Embed
What would you like to do?
NSScrollView のスクロール位置を同期する
@interface SSRefrectingScrollView : NSScrollView
@property BOOL inRefrecting;
@property (assign)IBOutlet SSRefrectingScrollView* counterPartView;
@end
@implementation SSRefrectingScrollView
- (void)reflectScrolledClipView:(NSClipView *)aClipView
{
[super reflectScrolledClipView:(NSClipView *)aClipView];
if (!self.inRefrecting && ![self inLiveResize]) {
self.inRefrecting=YES;
if (!self.counterPartView.inRefrecting) {
NSRect otherRect=[[self.counterPartView contentView]documentVisibleRect];
NSRect rect=[aClipView documentVisibleRect];
otherRect.origin.y=rect.origin.y;
otherRect.size.height=rect.size.height;
[[self.counterPartView documentView] scrollRectToVisible:otherRect];
}
self.inRefrecting=NO;
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.