0

I have an hierarchy of 3 view controllers in my navigation bar controller: view1->view2->view3. After the user finished with view3 I want to take him to view1. What is the best approach to do that?

thanks,

Nava

Nava Carmon
  • 4,523
  • 3
  • 40
  • 74

2 Answers2

1

Assuming that view3 and view2 have already been pushed onto your navigation controller, you can use -[UINavigationController popToRootViewControllerAnimated:] or -[UINavigationController popToViewController:animated:] to accomplish this.

iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
Ben Gottlieb
  • 85,404
  • 22
  • 176
  • 172
  • if I do it from my view3 how can I be sure I don't leave leaked views? both functions return an array of view on the stack. The question is whether I can release them? – Nava Carmon Jan 18 '10 at 07:53
  • If you've used -pushViewController:animated: to push them ONTO the stack, then popTo-whatever will not leak when you remove them from the stack. – Ben Gottlieb Jan 18 '10 at 11:43
-1

Simply make the action of a UIBarButtonItem on your UINavigationController (in this case, most likely your rightBarButtonItem) call

[self.myNavController pushViewController:view1 animated: YES];
Garrett H
  • 148
  • 7