嘿 StackOverflow 的人,
一段时间以来,我一直在尝试弄清楚这个问题,但无济于事,我需要一些帮助。我的应用程序底部附近有一个 UITableView
,但屏幕距离不足以让用户进行刷新。有谁知道如何缩短在 UITableView
和 UIWebView
中的 UIRefreshControl
上激活下拉刷新操作所需的距离?
先谢谢大家了!
最佳答案
您仍然可以使用 refreshControl,但需要进行一些修改!
将这些代码添加到您的 viewController 中:
var canRefresh = true
override func scrollViewDidScroll(scrollView: UIScrollView) {
if scrollView.contentOffset.y < -100 { //change 100 to whatever you want
if canRefresh && !self.refreshControl.refreshing {
self.canRefresh = false
self.refreshControl.beginRefreshing()
self.refresh() // your viewController refresh function
}
}else if scrollView.contentOffset.y >= 0 {
self.canRefresh = true
}
}
和往常一样,在 self.refresh() 函数的刷新逻辑末尾添加:
self.refreshControl.endRefreshing()
关于ios - 如何缩短 UIRefreshControl 的拉动距离来激活拉动刷新 Action ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20223386/