gpt4 book ai didi

ios - 将目标添加到 UIRefreshControl()

转载 作者:行者123 更新时间:2023-11-28 06:52:01 27 4
gpt4 key购买 nike

我做了一个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")

这是一个复习,工作正常,但我想添加一个 Action ,当我向下滚动到我的 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 结束时它正在减速并且您位于底部,然后您可以调用您的刷新器

关于ios - 将目标添加到 UIRefreshControl(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34613785/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com