I have pagination in my tableview and I scroll to bottom close to 5-6 pagination iterations down.
How do I scroll to top of the UITableview.
Solutions that I have tried with SO solutions Sol 1:
DispatchQueue.main.async {
let indexPath = IndexPath(row: 0, section: 0)
self.tableView.scrollToRow(at: indexPath, at: .top, animated: true)
}
Sol 2:
DispatchQueue.main.async {
self.tableView.setContentOffset(.zero, animated: true)
}
Sol 3:
tableView.scroll(to: .top, animated: true)
Sol 4: https://stackoverflow.com/a/48018130
whenever I am trying, I have checked the Scrollview contentsize of the tableview
The overall scroll is tableview.scrollview contentSize = [(414.0, 30662.666544596355)] when I tap on the button to scroll to top = [(0.0, 28960.0)], gradually it is decreasing, Ideally it should to top and make [(0.0, 0.0)] right ?
How can I achieve it ?