addTarget到UIRefreshControl()

时间:2016-01-05 14:16:15

标签: ios swift 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的底部时,它会刷新,就像我使用ValueChanged一样,但是对于底部

1 个答案:

答案 0 :(得分:1)

您可以使用内置的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