views:

42

answers:

2

Hi all,

I have a UINavigationController in my iPhone app controlling views in a drill-down fashion. I have 4 viewcontrollers that I pass through before I have a "Start over" button, where I would like the action to send the user back to the beginning of the view hierarchy.

[self.navigationController popToRootViewControllerAnimated:YES];

but it looks like it simply brings up a new rootviewcontroller on top of the current view controller.

Is there a way to pop the views back to the very beginning of the navigation drill down?

Any help would be great!

Many thanks, Brett

A: 

Something else is going on here. I use popToRootViewControllerAnimated in on of my apps and it does exactly what you are after.

Cannonade
You're right. I was trying to push a view incorrectly. popToRootViewControllerAnimated works exactly s described. Thanks!
Brett
@Brett awesome. Glad you sorted it out :)
Cannonade
A: 

and if you want to goback direction to your desired view controller then use the code bellow-

[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:3] animated:YES];

Here 'objectAtIndex:3' is the flow position(i.e. index) of your viewControllers. For the root it would be 0.

Vaibhav Saran