views:

58

answers:

1

Is it be possible to return to the first view of a NavigationController?

Example:

View 1 -> View 2 -> View 3 -> (An action is performed) Return to View 1

+1  A: 

UINavigationController is organized in a stack-like fashion, and it holds UIViewController instances, not views. If you want to return to a previous ViewController, you would typically use the popToViewController method. Calling this method pops view controllers until the specified view controller is at the top of the navigation stack. In the example that you give in your question, you would do

[navController popToViewController: viewController1 animated: NO];
luvieere
That didn't seem to work for me for some reason...it said the viewController I was trying to pop to doesn't exist...weird. Anywho, I used `[self.navigationController popToRootViewControllerAnimated:YES];` and it worked good enough for me. Thanks for pointing me in the right direction though!
rson