I'm using swift, I want to go to the top of a tableView upon a button press, like on twitter pressing the home button will take you to the top of your feed, so far I haven't been able to find a working solution, this is what I've tried :
tableView.setContentOffset(.zero, animated: true)
tableView.setContentOffset(CGPoint(x: 0.0, y: -tableView.contentInset.top), animated: true)
func scrollToTop(){
let indexPath = IndexPath(row: 0, section: 0)
tableView.scrollToRow(at: indexPath, at: .top, animated: true)
}
All solutions will only take you to an arbitrary cell, bonus points if you know the solution to do this upon a tab bar button click too