1

I have a UINavigationController which has several screens that implement a logical set of stepped tasks ...

Is there a way that on the last screen I can have logic on a done button that would take me to the start without having to step back through the screens ?

I am really looking for code examples of the logic I would need to put on the done button?

Many thanks

Yucel Bayram
  • 1,653
  • 2
  • 22
  • 41
rs2000
  • 147
  • 1
  • 9

4 Answers4

4

You have to pop directly to rootview controller instead of just popping.

use:

 [self.navigationController popToRootViewControllerAnimated:YES];
Preetam Jadakar
  • 4,479
  • 2
  • 28
  • 58
1

use this

[self.navigationController popToRootViewControllerAnimated:YES];

Hardik rami
  • 359
  • 4
  • 15
0

popToRootViewControllerAnimated -> It will pops all the view controllers on the stack except the root view controller and updates the display.

[yourNavigationController popToRootViewControllerAnimated:YES];

If you want to use popToViewController then

id rootView=[[self.navigationController viewControllers] objectAtIndex:0];
[self.navigationController popToViewController:rootView animated:YES];
Rajneesh071
  • 30,846
  • 15
  • 61
  • 74
0

You have two options to achieve this thing on DONE button ;

1) If your rootview is the view from where you want to restart than you can use as follows -

[self.navigationController popToRootViewControllerAnimated:YES];

2) Else you can re-initialize the navigation Controller & push to the start view.

Hope this will help.

Rohan
  • 2,939
  • 5
  • 36
  • 65