Reputation: 623
I have the following storyboard:
If the user navigates to view A1-2, then selects Tab B, then selects Tab A ... they will be presented with TableViewController A1-2 (their recent "Tab A exit point").
I would like them to be presented with TableViewController A1 if they navigate to Tab B then decide to 'go back' and select Tab A; NOT where they navigated to previously (i.e. TableViewController A1-2, or their recent "Tab A exit point").
Basically, any tab selected (other than the one currently selected) will present the root view controller of that particular tab.
Is this possible with my storyboard setup?
Many, many thanks for any feedback.
ADDENDUM:
Could I also go with the following code in view A1-2 (or A1-1, B1-2, B1-1):
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.popToRootViewControllerAnimated(true)
}
Thus effectively removing all views above the root view controller should the user switch tabs? And achieving my desired result?
Upvotes: 0
Views: 58
Reputation: 263
You can have A1-2 and A1-1 dismissed upon tab-bar switch, and vise-versa if needed.
//set tab bar delegate and call this method
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
if item == tabBarB {
//dismiss viewController A1-2 and A1-1
self.view.window!.viewControllerA1?.dismissViewControllerAnimated(false, completion: nil)
} else {
//dismiss miss viewController B1-2 and B1-1
self.view.window!.viewControllerB1?.dismissViewControllerAnimated(false, completion: nil)
}
}
Let me know if this is what you were looking for.
Upvotes: 1