繁体   English   中英

addTarget到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的底部时将使其刷新,就像我对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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM