In UIRefreshControl in iOS App, I think the default setting is that when I pull down UITableView(UISrollView) by about "100px", refresh begins.
I would like to make the above value smaller.(for example, "50px")
Is this possible?
If possible, please tell me sample codes.
// definition
extension UIRefreshControl {
func refreshManually() {
beginRefreshing()
sendActions(for: .valueChanged)
}
}
// usage
var isRefreshingManually = false
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y < -80.0 {
if !isRefreshingManually && !refreshControl.isRefreshing {
isRefreshingManually = true
refreshControl.refreshManually()
}
} else if scrollView.contentOffset.y >= 0 {
isRefreshingManually = false
}
}
My sample code is for UICollectionView, but UITableView & UIScollView work well, too.
Replace "-80.0" in my code to threshould value you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With