Created
March 9, 2018 07:49
-
-
Save 29satnam/32527edba843518b092a1ae43aaafb3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var previousController: UINavigationController? = nil; | |
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) { | |
guard let navigationController = tabBarController.viewControllers?[tabBarController.selectedIndex] as? UINavigationController else { | |
return | |
} | |
let canScrollToTop = navigationController == previousController | |
if let tableViewController = navigationController.topViewController as? ProfileTableViewController, canScrollToTop { | |
tableViewController.tableView.setContentOffset(.zero, animated: true) | |
} | |
previousController = navigationController | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment