I am encountering an issue where the event callback for UIRefreshControl is triggered multiple times when the UITableView is slid diagonally (top-left to bottom-right or vice versa). This behavior is not observed when sliding vertically. The issue disrupts the expected behavior of the refresh control and impacts the user experience negatively.
To replicate the problem, you can refer to the RefreshDemo.
In the BaseTableViewController.swift file, the _refresh(_:) method seems to serve as the entry point for the refresh control callback:
@objc
private func _refresh(_ control: UIRefreshControl) {
NSLog("Target refresh:")
refresh()
}
Within the ViewController.swift file, the refresh() method appears to manage the refresh control behavior:
extension ViewController {
override func refresh() {
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { [weak self] in
guard let this = self else { return }
this.refreshControl.endRefreshing()
this.tableView.reloadData()
}
}
}
Notably, adjusting the asyncAfter timestamp from 100 to 500 seems to mitigate the issue of multiple callbacks. However, it's unclear if this is the optimal solution or if there might be an underlying problem in the implementation.
I'm seeking guidance on the best approach to handle UIRefreshControl callbacks to avoid multiple triggers during diagonal UITableView slides. Any suggestions or insights into the root cause of this behavior would be greatly appreciated.