在UITableView下面添加一个UIRefreshControl

Dim*_*kas 3 uitableview ios uirefreshcontrol

有没有办法在UITableView下添加UIRefreshControl?我创建了一个我想要实现的预览.

iDe*_*per 17

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

在标题中声明如下

  UIActivityIndicatorView                             *spinner;
Run Code Online (Sandbox Code Playgroud)

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

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

添加这些,当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];
    }
}
Run Code Online (Sandbox Code Playgroud)

希望这会帮助你!