我做了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
一样,但是对于底部
答案 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
。