将目标添加到 UIRefreshControl()

addTarget to UIRefreshControl()

我做了一个UIRefreshControl:

refresher = UIRefreshControl()
refresher.attributedTitle = NSAttributedString(string: "refresh")
refresher.addTarget(self, action: "refreshed", forControlEvents: UIControlEvents.ValueChanged)
refresher.addTarget(self, action: "refreshed", forControlEvents: UIControlEvents.ApplicationReserved)
refresher.addTarget(self, action: "refreshed", forControlEvents: UIControlEvents."scrolled down to bottom")  

这是一个复习,工作正常,但我想添加一个动作,当我向下滚动到 tableView 的底部时,它会刷新,就像我对 [=13= 所做的那样], 但对于底部

您可以使用内置的 scrollViewDidEndDecelerating

func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
    let bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height
    if bottomEdge >= scrollView.contentSize.height {
        // Reached bottom, do your refresh
        print("Bottom")
    }
}

scrollView 结束时它正在减速并且你在底部,然后你可以调用你的 refresher