![](/img/trans.png)
[英]UIRefreshControl addTarget action causing “unrecognized selector” error
[英]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
的底部时将使其刷新,就像我对ValueChanged
所做的一样,但对于底部
您可以使用内置的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
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.