UIRefreshControl at the bottom of the UITableView iOS6?

前端 未结 8 2013
你的背包
你的背包 2020-12-01 06:27

Is it possibile add UIRefreshControl at the bottom of the UITableView? I would use it to load more data. Please, Any suggest?

8条回答
  •  [愿得一人]
    2020-12-01 07:08

    You can use UIView to customize your refreshControl at bottom. Create UIView and add it to UITableView as footerView.

    UIView* footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
    
    [footerView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"refreshImage.png"]]];
    
    tableView.tableFooterView = footerView;
    

    Hide it: tableView.tableFooterView.hidden = YES;

    Implement UIScrollView delegate -

    (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)
        {
                 tableView.tableFooterView.hidden = NO;
                // call method to add data to tableView
        }
    
    }
    

    before adding data to tableView save current offset by CGPoint offset = tableView.contentOffset;

    call reloadData then set previously saved offset back to tableView [tableView setContentOffset:offset animated:NO];

    So that you can feel new data added at bottom.

提交回复
热议问题