How Do I Shorten the Pull Distance on UIRefreshControl to Activate the Pull to Refresh Action?

后端 未结 5 1072
傲寒
傲寒 2021-02-07 09:27

Hey StackOverflow People,

I\'ve been trying to figure out this question for some time now but to no avail and I need some help. I have a UITableView close t

5条回答
  •  名媛妹妹
    2021-02-07 10:01

    For Swift 3.2 and above :

    var canRefresh = true
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if scrollView.contentOffset.y < -100 {
            if canRefresh && !self.refreshControl.isRefreshing {
                self.canRefresh = false
                self.refreshControl.beginRefreshing()
                self.handleRefresh()
            }
        } else if scrollView.contentOffset.y >= 0 {
            self.canRefresh = true
        }
    }
    

提交回复
热议问题