小編給大家分享一下iOS中EGORefreshTableHeaderView怎么用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
創(chuàng)新互聯(lián)2013年開創(chuàng)至今,先為青川等服務(wù)建站,青川等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為青川企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
1.把EGORefreshTableHeaderView.h和EGORefreshTableHeaderView.m文件拉入到工程
2.viewcontroller文件添加引用#import "EGORefreshTableHeaderView.h"和協(xié)議<EGORefreshTableHeaderDelegate>
3.定義對(duì)象
EGORefreshTableHeaderView *refreshView;
BOOL reloading;
//注意reloading是必須的
4 實(shí)現(xiàn)delegate
#pragma mark - EGORefreshTableHeaderDelegate Methods
//下拉控件刷新觸發(fā)事件
- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{
[self reloadTableViewDataSource];
}
- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{
return reloading; // should return if data source model is reloading
}
- (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{
return [NSDate date]; // should return date data source was last changed
}
#pragma mark - UIScrollViewDelegate Methods
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
[refreshView egoRefreshScrollViewDidScroll:scrollView];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
[refreshView egoRefreshScrollViewDidEndDragging:scrollView];
}
注意要實(shí)現(xiàn)UIScrollViewDelegate
5 添加load數(shù)據(jù)的函數(shù)和load完數(shù)據(jù)的函數(shù)
#pragma mark Data Source Loading / Reloading Methods
//下拉動(dòng)作觸發(fā)事件調(diào)用的函數(shù)。在這里發(fā)送數(shù)據(jù)請(qǐng)求
- (void)reloadTableViewDataSource{
// should be calling your tableviews data source model to reload
// put here just for demo
NSLog(@"dragging!!!");
timer = [NSTimer scheduledTimerWithTimeInterval:5 target:selfselector:@selector(doneLoadingTableViewData) userInfo:nil repeats:NO];
reloading = YES;
}
//請(qǐng)求結(jié)束函數(shù)。在這里要關(guān)閉下拉的視圖.并更新表視圖
- (void)doneLoadingTableViewData{
// model should call this when its done loading
NSLog(@"stop loading");
timer = nil;
reloading = NO;
[refreshView egoRefreshScrollViewDataSourceDidFinishedLoading:self.tableView];
[listData addObject:[[NSString alloc] initWithFormat:@"%d",[listData count]]];
[self.tableView reloadData];
}
以上是“iOS中EGORefreshTableHeaderView怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!