Skip to content

Instantly share code, notes, and snippets.

@hetima
Created March 12, 2013 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hetima/5142318 to your computer and use it in GitHub Desktop.
Save hetima/5142318 to your computer and use it in GitHub Desktop.
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