Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Why don't you use <code>UINavigationController</code>? You can use both <code>popToRootViewControllerAnimated:</code> and <code>popViewControllerAnimated:</code> for your purpose.</p> <p>As such if you do,</p> <pre><code>[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES]; </code></pre> <p>You should go back to <code>1</code>.</p> <p>Excerpt from <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW30" rel="nofollow"><code>dismissModalViewControllerAnimated</code></a>,</p> <p><em>If you present several modal view controllers in succession, and thus build a stack of modal view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.</em></p> <p><strong>Using Navigation Controller</strong></p> <p>For navigation controller to work, instead of where your load your <code>view1</code> you will do this,</p> <pre><code>View1 *myView = [[[View1 alloc] initWithNibName:@"View1" bundle:nil] autorelease]; UINavigationController * navController = [[[UINavigationController alloc] initWithRootViewController:myView] autorelease] [mainNavController presentModalViewController:navController animated:YES]; </code></pre> <p><em>This is assuming that <code>view1</code> was the <code>rootViewController</code></em></p> <p>Once you've the navigation controller set up then you can load <code>view2</code> like this,</p> <pre><code>View2 *myView = [[View2 alloc] initWithNibName:@"View2" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:myView animated:YES]; [myView release]; </code></pre> <p>In such case,</p> <p><strong>Cancel</strong></p> <pre><code>[self.navigationController popViewControllerAnimated:YES]; </code></pre> <p><strong>Complete</strong></p> <pre><code>[self.navigationController popToRootViewControllerAnimated:YES]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload