Created
September 11, 2012 02:24
-
-
Save ying80/3695472 to your computer and use it in GitHub Desktop.
Fix for egoRefreshScrollViewDidEndDragging not setting the correct state when refresh finishes before loading is set
This file contains hidden or 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
//---------------------------------------- | |
// *** with block **** | |
- (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView { | |
BOOL _loading = NO; | |
if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) { | |
_loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self]; | |
} | |
if (scrollView.contentOffset.y <= - 65.0f && !_loading) { | |
[self setState:EGOOPullRefreshLoading]; | |
[UIView animateWithDuration:0.2 animations:^{ | |
scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f); | |
} completion:^(BOOL finished) { | |
if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) { | |
[_delegate egoRefreshTableHeaderDidTriggerRefresh:self]; | |
} | |
}]; | |
} | |
} | |
//---------------------------------------- | |
// *** without block **** | |
- (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView { | |
BOOL _loading = NO; | |
if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) { | |
_loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self]; | |
} | |
if (scrollView.contentOffset.y <= - 65.0f && !_loading) { | |
[self setState:EGOOPullRefreshLoading]; | |
[UIView beginAnimations:nil context:NULL]; | |
[UIView setAnimationDuration:0.2]; | |
scrollView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f); | |
[UIView setAnimationDelegate:self]; | |
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)]; | |
[UIView commitAnimations]; | |
} | |
} | |
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag | |
{ | |
if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) { | |
[_delegate egoRefreshTableHeaderDidTriggerRefresh:self]; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment