EGOTableViewPullRefresh实现下拉刷新
首先定义EGORefreshTableHeaderView *_refreshView和BOOL _isRefresh;实现EGORefreshTableHeaderDelegate
1 //定义下拉刷新试图 2 _refreshView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0, -[UIScreen mainScreen].bounds.size.height, 320, [UIScreen mainScreen].bounds.size.height)]; 3 _refreshView.delegate = self; 4 [self.tableView addSubview:_refreshView];
1 //实现scroller的配置 2 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 3 [_refreshView egoRefreshScrollViewDidScroll:scrollView]; 4 } 5 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { 6 [_refreshView egoRefreshScrollViewDidEndDragging:scrollView]; 7 //实现上啦加载更多的选项 8 if (scrollView.contentOffset.y+scrollView.frame.size.height>scrollView.contentSize.height+40) { 9 } 10 }
1 //实现它的代理 2 - (NSDate *)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView *)view { 3 return [NSDate date]; 4 } 5 - (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView *)view { 6 return _isRefresh; 7 } 8 - (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView *)view { 9 _isRefresh = YES; 10 /*刷新的其他操作*/ 11 }
//在结束刷新的地方调用 _isRefresh = NO; [_refreshView egoRefreshScrollViewDataSourceDidFinishedLoading:self.tableView];