I have a Tab Bar Controller, which refers to two Navigation Controllers, these Navigation Controllers refer each to one view Controller. Form this View Controller you can go to another View Controller. If I switch from the first "Workflow" (e.g. thrird page) to the second and back with the Tab Bar I have to click the Button for the first Workflow twice to get to the initial view. Can I make my program to do that only by one click ? I hope you understand my problem and the structure of the program.
IB means Interface Builder.
I do not understand what you copied on line 4
Here is my code:
Note: it is not a very good idea to start a new line 3. It is better to write on a single line:
And don't forget to unwrap self.viewControllers
I do not understand what you copied on line 4
Code Block override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) { let rootView = self.viewControllers [self.selectedIndex] as! UINavigationController rootView.popToRootView // here the editor says that it does not work/exist // }
Here is my code:
Code Block override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) { if self.selectedIndex == 0 { let rootView = self.viewControllers![self.selectedIndex] as! UINavigationController rootView.popToRootViewController(animated: false) } }
Note: it is not a very good idea to start a new line 3. It is better to write on a single line:
Code Block let rootView = self.viewControllers![self.selectedIndex] as! UINavigationController
And don't forget to unwrap self.viewControllers