Add a UIRefreshControl below a UITableView [duplicate]

依然范特西╮ 提交于 2019-12-06 08:52:28

问题


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


回答1:


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

Declare below in your header

  UIActivityIndicatorView                             *spinner;

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;

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

Hope This will help you out !



来源:https://stackoverflow.com/questions/20837787/add-a-uirefreshcontrol-below-a-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!