最近工作涉及到了下拉刷新的功能,贴出来,跟大家一起分享,我把RefreshView代码上传~~
1,添加RefreshView到tableView
NSArray *nils = [[NSBundlemainBundle]loadNibNamed:@"RefreshView"owner:selfoptions:nil];
self.refreshView = [nilsobjectAtIndex:0];
[refreshViewsetupWithOwner:self.m_tabledelegate:self];
2,实现几个函数
// 停止,可以触发自己定义的停止方法
- (void)stopLoading
{
[refreshViewstopLoading];
}
// 开始,可以触发自己定义的开始方法
- (void)startLoading
{
[refreshViewstartLoading];
// 模拟3秒后停止
[self performSelector:@sexlector(stopLoading) withObject:nil afterDelay:2];
}
// 刷新
- (void)refresh
{
[selfstartLoading];
}
#pragma mark - RefreshViewDelegate
- (void)refreshViewDidCallBack
{
[self refresh];
}
拖拉的时候 需要有这个
// 刚拖动的时候
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[refreshViewscrollViewWillBeginDragging:scrollView];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
[refreshViewscrollViewDidEndDragging:scrollView willDecelerate:decelerate];
}
// 拖动过程中
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[refreshViewscrollViewDidScroll:scrollView];
//下拉到最底部时显示更多数据
}
RefreshView下载地址:http://download.csdn.net/detail/heicainiuniu/4575652