IOS 学习笔记 —— EGOTableViewPullRefresh使用 (一)


1.

//下拉刷新
    EGORefreshTableHeaderView *refreshHeaderView;
    BOOL egoLoading;

2.

//下拉刷新
    if (refreshHeaderView == nil) {
        //初始化下拉刷新组件
//        EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, -320.0f, self.view.frame.size.width, 320)];
        EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableBulletin.bounds.size.height, self.view.frame.size.width, self.tableBulletin.bounds.size.height)];
        
        view.delegate = self;//设置委托
        //添加下拉刷新控件
        [self.tableBulletin addSubview:view];
        refreshHeaderView = view;
    }
    //update the last updae date
    [refreshHeaderView refreshLastUpdatedDate];

3.

#pragma mark - EGORefresh下拉刷新处理
//开始重新加载时调用
- (void)reloadTableViewDataSource
{
    egoLoading = YES;
}
//完成加载时调用
- (void)doneLoadingTableViewData
{
    egoLoading = NO;
    [refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.tableBulletin];
}
#pragma mark - UIScrollViewDelegate Methods 滚动控件的委托方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    [refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];
}
#pragma mark - EGORefreshTableHeaderDelegate Methods
- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView *)view
{
    [self reloadTableViewDataSource];
    
    [self refresh];//执行刷新操作
}
//上拉更新
- (void)egoRefreshTableHeaderDidTriggerToBottom
{
    NSLog(@"5. DidTriggerToBottom");
////    if (!isLoading) {
////        [self performSelector:@selector(reload:)];
////    }
}

- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView *)view
{
    return egoLoading;
}

- (NSDate *)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView *)view
{
    return [NSDate date];
}

4.



你可能感兴趣的:(IOS 学习笔记 —— EGOTableViewPullRefresh使用 (一))