UIRefreshControl on viewDidLoad

前端 未结 4 1983
再見小時候
再見小時候 2020-12-13 01:02

I\'m using the following code to create a UIRefreshControl:

- (void) viewDidLoad
{
    [super viewDidLoad];

    UIRefreshControl *refreshControl = [[UIRefre         


        
4条回答
  •  一个人的身影
    2020-12-13 01:26

    Manually modifying the contentOffset is insecure and wrong and can lead to unexpected behavior in some cases. This solution works without touching the contentOffset at all:

    func showRefreshControl(show: Bool) {
        if show {
            refreshControl?.beginRefreshing()
            tableView.scrollRectToVisible(CGRectMake(0, 0, 1, 1), animated: true)
        } else {
            refreshControl?.endRefreshing()
        }
    }
    

提交回复
热议问题