Wizard style navigation, dismissing a view and showing another one
<p>I'm making a set of screens similar to a wizard and I'd like to know how to make a view dismiss itself and its parent view and immediately show a 'DoneScreen' without worrying about resource leaks. My views look like the following:</p>

<pre><code>Base -&gt; Level1 -&gt; DoneScreen
               -&gt; Level2 -&gt; DoneScreen
</code></pre>

<p>The Level1 controller is a navigation controller created with a view.xib and shown with </p>

<pre><code>[self presentModalViewController ...]
</code></pre>

<p>by the Base controller. The Level1 controller is also responsible for creating the 'DoneScreen' which may be shown instead of the Level2 Screen based on a certain criteria.</p>

<p>When the user taps a button on the screen, the Level1 controller instantiates the the Level2 controller and it displays it via</p>

<pre><code>[self.navigationController pushViewController ..]
</code></pre>

<p>and Level2 controller's view has a 'Next' button. </p>

<p>When the use hits the 'Next' button in the Level2 screen, I need to dismiss the current Level2's view as well as the Level1's view and display the 'DoneScreen', which would have been created and passed in to the Level2 controller from Level1. (partly to reduce code duplication, and partly to separate responsibilities among the controllers) In the Level2 controller, if I show the 'DoneScreen' first and dismiss itself with </p>

<pre><code>[self.navigationController popViewControllerAnimated:YES];
</code></pre>

<p>then the Level1 controller's modal view is still present above the 'Base' but under the Done screen. What's a good way to clear out all of these views except the Base and then show the 'DoneScreen'?</p>

<p>Any good suggestions on how to get this done in a simple but elegant manner?</p>
