最近做项目中,开始是模仿的新浪微博的下拉刷新,后来发现数据量多,需要做分页刷新也就是 下滑刷新,通过UIScrollView控件的事件来判断是上拉还是下拉刷新,然后做响应的操作,此处代码贴出来,希望大家多给建议:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//康海涛测试Ok的
CGPoint offset1 = scrollView.contentOffset;
CGRect bounds1 = scrollView.bounds;
CGSize size1 = scrollView.contentSize;
UIEdgeInsets inset1 = scrollView.contentInset;
float y1 = offset1.y + bounds1.size.height - inset1.bottom;
float h1 = size1.height;
if (y1 > tableViewController.frame.size.height) {
flagShuaxin = YES;
}
else if (y1 < tableViewController.frame.size.height) {
flagShuaxin = NO;
}
else if (y1 == tableViewController.frame.size.height) {
DLog(@"%@", flagShuaxin ? @"上拉刷新" : @"下拉刷新");
}
}
}