有没有办法在UITableView下添加UIRefreshControl?我创建了preview我想要实现的目标。
答案 0 :(得分:17)
这些不会提供UIRefresh控件,但您可以在屏幕底部添加这些
在标题
中声明如下 UIActivityIndicatorView *spinner;
在您的实现
中的ViewDidLoad中初始化相同内容spinner = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
[spinner stopAnimating];
spinner.hidesWhenStopped = NO;
spinner.frame = CGRectMake(0, 0, 320, 44);
self.tableviewName.tableFooterView = spinner;
添加这些,当tableview滚动
时将调用它- (void)scrollViewDidEndDragging:(UIScrollView *)aScrollView
willDecelerate:(BOOL)decelerate{
CGPoint offset = aScrollView.contentOffset;
CGRect bounds = aScrollView.bounds;
CGSize size = aScrollView.contentSize;
UIEdgeInsets inset = aScrollView.contentInset;
float y = offset.y + bounds.size.height - inset.bottom;
float h = size.height;
float reload_distance = 50;
if(y > h + reload_distance) {
NSLog(@"load more data");
[spinner startAnimating];
}
}
希望这会帮助你!