Created
March 12, 2013 11:52
-
-
Save hetima/5142318 to your computer and use it in GitHub Desktop.
NSScrollView のスクロール位置を同期する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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