ios 下拉刷新

 
实现的开源框架是: https://github.com/enormego/EGOTableViewPullRefresh

1.实现过程很简单,下载相应的demo,然后拷贝资源文件和EGORefreshTableHeaderView.h和EGORefreshTableHeaderView.m到相依的工程中.

2. 添加QuartzCore.framework组建

3. 在table所在的类中.h 文件中添加如下代码:


@interface iphone_navtaViewController :UITableViewController<EGORefreshTableHeaderDelegate>{
   
     EGORefreshTableHeaderView *_refreshHeaderView;
//  Reloading var should really be your tableviews datasource
//  Putting it here for demo purposes 
     BOOL _reloading;
} 
- (void)reloadTableViewDataSource;
- (void)doneLoadingTableViewData;
@end


然后在.m文件中实现以下个方法

#pragma mark -
#pragma mark EGORefreshTableHeaderDelegate Methods

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

- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{
	//NSLog(@"=egoRefreshTableHeaderDataSourceIsLoading");
	return _reloading; // should return if data source model is reloading
	
}

- (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{
	NSLog(@"=egoRefreshTableHeaderDataSourceLastUpdated");
	return [NSDate date]; // should return date data source was last changed
	
}

#pragma mark -
#pragma mark Data Source Loading / Reloading Methods

- (void)reloadTableViewDataSource{
	NSLog(@"==reloadTableViewDataSource");
	//  should be calling your tableviews data source model to reload
	//  put here just for demo
	_reloading = YES;
	
}

- (void)doneLoadingTableViewData{
	NSLog(@"==doneLoadingTableViewData");

	//  model should call this when its done loading
	_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];
	
}


以上方法主要的调用顺序是: 下拉的时候会一直调用   egoRefreshTableHeaderDataSourceIsLoading

                                              释放之后会调用    egoRefreshTableHeaderDidTriggerRefresh ——>  reloadTableViewDataSource(这个 方法中写松手后要实现的操作)

     当reloadTableViewDataSource方法执行完后会调用    doneLoadingTableViewData(这个方法实现执行完 成后的操作)








你可能感兴趣的:(ios,Date,框架,table,iPhone,interface)