How to scroll UITableView to the top

There is an instance method of UIScrollView called setContentOffset(_:animated:). As UITableView is a subclass of UIScrollView, you could also use this method.

If you need to scroll the table view to the top, you just call this method like below:

tableView.setContentOffset(.zero, animated: true)

Hope this helps,

DigitalOcean Referral Badge