Skip to content

Instantly share code, notes, and snippets.

@aqubi
Created May 30, 2020 07:56
Show Gist options
  • Save aqubi/ac66ac5d51cf7560d6eca97ab0e354be to your computer and use it in GitHub Desktop.
Save aqubi/ac66ac5d51cf7560d6eca97ab0e354be to your computer and use it in GitHub Desktop.
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if tabBarController.selectedViewController == viewController, let split = viewController as? UISplitViewController {
if split.isCollapsed {
if let navigation = split.viewControllers.first as? UINavigationController {
navigation.popToRootViewController(animated: true)
}
} else if split.displayMode == .primaryHidden {
let mode = split.preferredDisplayMode
split.preferredDisplayMode = mode
}
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment