在UITableView下面添加一个UIRefreshControl [英] Add a UIRefreshControl below a UITableView

查看:58
本文介绍了在UITableView下面添加一个UIRefreshControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在UITableView下面添加UIRefreshControl?我为要实现的目标创建了预览.

Is there any way to add a UIRefreshControl below a UITableView? I created a preview of what I want to achieve.

推荐答案

这些不会提供UIRefresh控件,但您可以将它们添加到屏幕底部

These won't give the UIRefresh Controls but you can add these at the bottom of the Screen

在标题下方声明

  UIActivityIndicatorView                             *spinner;

在实现中的ViewDidLoad中初始化相同的内容

Initialise the same in ViewDidLoad in your implementation

spinner = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
    [spinner stopAnimating];
    spinner.hidesWhenStopped = NO;
    spinner.frame = CGRectMake(0, 0, 320, 44);
    self.tableviewName.tableFooterView = spinner;

添加这些内容,并且在滚动tableview时将被调用

Add These and it will be called when tableview Scrolled

- (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];
    }
}

希望这会帮助您!

这篇关于在UITableView下面添加一个UIRefreshControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆