Created
May 29, 2012 05:25
-
-
Save soffes/2822776 to your computer and use it in GitHub Desktop.
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 SSPullToRefreshView () | |
@property (nonatomic, weak, readwrite) UIScrollView *scrollView; | |
@end | |
@implementation SSPullToRefreshView | |
@synthesize scrollView = _scrollView; | |
- (void)setScrollView:(UIScrollView *)scrollView { | |
void *context = (__bridge void *)self; | |
[self.scrollView removeObserver:self forKeyPath:@"contentOffset" context:context]; | |
_scrollView = scrollView; | |
_defaultContentInset = self.scrollView.contentInset; | |
[self.scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:context]; | |
} | |
- (void)dealloc { | |
self.scrollView = nil; | |
} | |
- (void)removeFromSuperview { | |
// _scrollView is nil already when this is called so removing the KVO doesn't do anything | |
self.scrollView = nil; | |
[super removeFromSuperview]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment