Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug and optimized code #260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions SVPullToRefresh/UIScrollView+SVInfiniteScrolling.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,13 @@ - (void)setScrollViewContentInset:(UIEdgeInsets)contentInset {
#pragma mark - Observing

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if([keyPath isEqualToString:@"contentOffset"])
[self scrollViewDidScroll:[[change valueForKey:NSKeyValueChangeNewKey] CGPointValue]];
if([keyPath isEqualToString:@"contentOffset"]) {
CGPoint newPoint = [[change valueForKey:NSKeyValueChangeNewKey] CGPointValue];
//only excute when pull up
if (newPoint.y >= 0) {
[self scrollViewDidScroll:newPoint];
}
}
else if([keyPath isEqualToString:@"contentSize"]) {
[self layoutSubviews];
self.frame = CGRectMake(0, self.scrollView.contentSize.height, self.bounds.size.width, SVInfiniteScrollingViewHeight);
Expand Down
9 changes: 7 additions & 2 deletions SVPullToRefresh/UIScrollView+SVPullToRefresh.m
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,13 @@ - (void)setScrollViewContentInset:(UIEdgeInsets)contentInset {
#pragma mark - Observing

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if([keyPath isEqualToString:@"contentOffset"])
[self scrollViewDidScroll:[[change valueForKey:NSKeyValueChangeNewKey] CGPointValue]];
if([keyPath isEqualToString:@"contentOffset"]) {
CGPoint newPoint = [[change valueForKey:NSKeyValueChangeNewKey] CGPointValue];
//only excute when pull down
if (newPoint.y <= 0) {
[self scrollViewDidScroll:newPoint];
}
}
else if([keyPath isEqualToString:@"contentSize"]) {
[self layoutSubviews];

Expand Down