I want to scroll to the top of my tableView and also show the largeTitle in the navigationBar when I tap on the tab in the tabbar.
Using the scrollToRow method does not show the largeTitle:
extension TableViewConstroller: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
if tabBarController.selectedIndex == 1 {
let indexPath = IndexPath(row: 0, section: 0)
tableView.scrollToRow(at: indexPath, at: .top, animated: true)
}
}
}
I also tried
self.tableView.scrollRectToVisible(CGRect(x: 0, y: -64, width: 1, height: 1), animated: true)
This works sometimes, but if I scroll way down the tableView, the navigationBar is still collapsed when this method scrolls up.
What can I do to mimic the behavior of the tableView's scrollsToTop property that does scroll to the top and shows the largeTitle? It animates very smoothly and always shows the large navigationBar.