iOS 刷新

-(EGORefreshTableHeaderView *)refresh//先初始化
{
    EGORefreshTableHeaderView *egoView=[[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.view.bounds.size.height, self.view.frame.size.width, self.view.bounds.size.height)];
    egoView.delegate=self;
    [egoView refreshLastUpdatedDate];
    return egoView;
}

-(void)tableViewInitShow//将刷新添加到tableview
{
    _refreshHeaderTableView = [self refresh];
    [m_tableView addSubview:_refreshHeaderTableView];
}


写上它的代理方法:例子:
-(void)reloadTableViewDataSource
{
    _reLoading=YES;
}

-(void)doneLoadingTableViewData
{
    _reLoading = NO;
    if (flag%2==0)
    [_refreshHeaderTableView egoRefreshScrollViewDataSourceDidFinishedLoading:m_tableView];
    else{
        [_refreshHeaderCollectionView egoRefreshScrollViewDataSourceDidFinishedLoading:m_collectionView];
    }
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (flag%2==0)
        [_refreshHeaderTableView egoRefreshScrollViewDidScroll:scrollView];
    else{
        [_refreshHeaderCollectionView egoRefreshScrollViewDidScroll:scrollView];
    }
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    if (flag%2==0)
        [_refreshHeaderTableView egoRefreshScrollViewDidEndDragging:scrollView];
    else{
        [_refreshHeaderCollectionView egoRefreshScrollViewDidEndDragging:scrollView];
    }
}

- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view
{
   
    [self reloadTableViewDataSource];
    [self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:3.0];
   
}

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

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

你可能感兴趣的:(iOS 刷新)