Take the 2-minute tour ×

OK so this is the scenario:

I have a Tab bar application that has a UINavigationController in each tab. Lets say I have two tabs, "Home" and "Signout". In "Home" the user follows a UINavigation based navigation down 3 levels and presses submit. After that they click on "Signout", click on the signout button.

What I want to do is to:

Take the user back to the first tab "Home", and then do a "Pop to root navigation controller"

My code in Signout is :

[[self tabBarController]setSelectedIndex:0]; //this takes me to the first tab "Home"

[self.navigationController popToRootViewControllerAnimated:YES]; //this does not work

How do I get about doing this?

share|improve this question
AFAIK, your first line is frowned upon in Apple's guidelines. You shouldn't set tab item programmatically. –  jv42 Jun 16 '11 at 13:52
Why are you taking control to first tab and then popping navigation control at the same time. ? –  Legolas Jun 16 '11 at 14:01
I am taking user to home screen because they just clicked sign out. When the next time the user signs on, I want them to start from the same step every time and not the "signout" screen –  milof Jun 16 '11 at 14:12
add comment

1 Answer

up vote 1 down vote accepted

You need to invoke the pop command on the proper controller, ie do something like:

UIViewController *selectedController = [[self tabBarController] selectedController];
[[selectedController navigationController] popToRootViewControllerAnimated: YES];
share|improve this answer
add comment

Your Answer


