Search code examples
swiftuinavigationcontrolleruitabbarcontrolleruinavigationbaruitabbar

TabBar and Navigation Controller reset


My Mainscreen contains a TabBar with three Buttons. One of these Buttons opens a NavigationContoller for a flow with four additional ViewController. At the end of this flow a popup comes up with a Screen "Gratulations, bla bla bla..." In this view is a UIButton "Back to main screen" which move the Mainscreen to "tabBarController?.selectedIndex = 0" so far it works! But if I click the TabbarButton again I see the screen "Gratulations, bla bla bla..." again. can someone tell me who I Reset the NavigationController that the flow begins again

Thanks Dennis


Solution

  • Add the following line of code when the user presses "Back to main screen" button:

    navigationController?.popToRootViewControllerAnimated(true)