Reputation: 3
Im working on an App for iOS, thats uses the navigationController to switch betweens views. I'm trying to return from to the root viewcontroller from the third view.
I have succeeded in the Main.Storyboard, with dragging a button from third to root view, but then the NavigationController just continues the stack.
Is it possible to make a command from third view, to return to root ViewController, without the NavigationController Bar showing the "Back" button and keeping track and without reseting any Bools.
Upvotes: 0
Views: 653
Reputation: 1318
If you want to hide the back button from the navigation bar.Then write the code in third view's viewDidLoad or in viewWillAppear-
self.navigationItem.hidesBackButton=YES;
And Now write the code in the body of the action button.Such as-
[self.navigationController popToRootViewControllerAnimated:YES];
Let me know if it works for you.Thank you
Upvotes: 1
Reputation: 2063
You can use the [UINavigationCobtroller popToRootViewControllerAnimated:]
to close all the view hierarchy to the first but for the remaining issues you can find plenty of answers on SO.
Upvotes: 1