码迷,mamicode.com
首页 > 移动开发 > 详细

ios EGORefreshTableHeaderView下拉刷新

时间:2015-05-30 16:38:14      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

第一步  将EGORefreshTableHeaderView.h、EGORefreshTableHeaderView.m两个文件,以及Enormego提供的那一套图片包拖进你的工程里。
第二步 
RootViewController.h添加相应的元素:

#import "EGORefreshTableHeaderView.h"

@interface RootViewController : UIViewController  <UITableViewDataSource,UITableViewDelegate,EGORefreshTableHeaderDelegate,UIScrollViewDelegate>{

EGORefreshTableHeaderView *_refreshHeaderView;
BOOL _reloading;
}

RootViewController.m添加相应的元素:
-(void)viewDidLoad {
[super viewDidLoad];
//创建self.tableView的方法和委托暂时去掉,不属于本篇讨论内容


EGORefreshTableHeaderView *view =[[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.view.frame.size.width, self.tableView.bounds.size.height)];
view.delegate = self;
[self.tableView addSubview:view];
_refreshHeaderView = view;
[_refreshHeaderView refreshLastUpdatedDate];
}

 

#pragma mark -
#pragma mark Data Source Loading / Reloading Methods
-(void)reloadTableViewDataSource{
_reloading =YES;
}

-(void)doneLoadingTableViewData{
_reloading =NO;
[_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.tableView];

}


#pragma mark -
#pragma mark UIScrollViewDelegate Methods
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
[_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
}

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
[_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];
}


#pragma mark -
#pragma mark EGORefreshTableHeaderDelegate Methods 
-(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 EGORefreshTableHeaderView下拉刷新

标签:

原文地址:http://www.cnblogs.com/huangzs/p/4540474.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!