diff --git a/Demo/TableViewPull/.DS_Store b/Demo/TableViewPull/.DS_Store deleted file mode 100644 index b17ff1b..0000000 Binary files a/Demo/TableViewPull/.DS_Store and /dev/null differ diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h index 0ec72f0..4d278ee 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h @@ -30,7 +30,8 @@ typedef enum{ EGOOPullRefreshPulling = 0, EGOOPullRefreshNormal, - EGOOPullRefreshLoading, + EGOOPullRefreshLoading, + EGOOPullRefreshStreaming, } EGOPullRefreshState; @protocol EGORefreshTableHeaderDelegate; @@ -55,6 +56,8 @@ typedef enum{ - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView; - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView; - (void)egoRefreshScrollViewDataSourceDidFinishedLoading:(UIScrollView *)scrollView; +- (void)egoRefreshScrollViewDataSourceDidBeginStreaming:(UIScrollView *)scrollView; +- (void)egoRefreshScrollViewDataSourceDidEndStreaming:(UIScrollView *)scrollView; @end @protocol EGORefreshTableHeaderDelegate @@ -62,4 +65,5 @@ typedef enum{ - (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view; @optional - (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view; +- (BOOL)egoRefreshTableHeaderDataSourceIsStreaming:(EGORefreshTableHeaderView *)view; @end diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m index 56b345b..94e2bfa 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m @@ -90,7 +90,6 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI _activityView = view; [view release]; - [self setState:EGOOPullRefreshNormal]; } @@ -107,7 +106,11 @@ - (id)initWithFrame:(CGRect)frame { #pragma mark Setters - (void)refreshLastUpdatedDate { - + if (_state == EGOOPullRefreshStreaming) { + _lastUpdatedLabel.text = nil; + return; + } + if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceLastUpdated:)]) { NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self]; @@ -171,11 +174,22 @@ - (void)setState:(EGOPullRefreshState)aState{ [CATransaction commit]; break; + case EGOOPullRefreshStreaming: + + _statusLabel.text = NSLocalizedString(@"Streaming...", @"Streaming status"); + [_activityView startAnimating]; + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + _arrowImage.hidden = YES; + [CATransaction commit]; + + break; default: break; } _state = aState; + [self refreshLastUpdatedDate]; } @@ -214,11 +228,15 @@ - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView { - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView { BOOL _loading = NO; + BOOL _streaming = NO; if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) { _loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self]; } + if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsStreaming:)]) { + _streaming = [_delegate egoRefreshTableHeaderDataSourceIsStreaming:self]; + } - if (scrollView.contentOffset.y <= - 65.0f && !_loading) { + if (scrollView.contentOffset.y <= - 65.0f && !_loading && !_streaming) { if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) { [_delegate egoRefreshTableHeaderDidTriggerRefresh:self]; @@ -235,14 +253,36 @@ - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView { } - (void)egoRefreshScrollViewDataSourceDidFinishedLoading:(UIScrollView *)scrollView { - - [UIView beginAnimations:nil context:NULL]; - [UIView setAnimationDuration:.3]; - [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)]; - [UIView commitAnimations]; - - [self setState:EGOOPullRefreshNormal]; + if (_state == EGOOPullRefreshLoading) { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:.3]; + [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)]; + [UIView commitAnimations]; + } + + [self setState:EGOOPullRefreshNormal]; +} +- (void)egoRefreshScrollViewDataSourceDidBeginStreaming:(UIScrollView *)scrollView { + if (_state == EGOOPullRefreshLoading) { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:.3]; + [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)]; + [UIView commitAnimations]; + } + + [self setState:EGOOPullRefreshStreaming]; +} + +- (void)egoRefreshScrollViewDataSourceDidEndStreaming:(UIScrollView *)scrollView { + if (_state == EGOOPullRefreshLoading) { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:.3]; + [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)]; + [UIView commitAnimations]; + } + + [self setState:EGOOPullRefreshNormal]; }