title: iphone NavigationController clear views stack
body: <p>I have an iphone application that uses a navigation controller. In that controller I push some views. In some cases I want to "clear" the views stack, leave only the rootViewController of the navigation controller in the stack and push another viewController I have. </p>
  
  <p>Can someone give me an example on how to do this? I don't see any method that clears the stack.</p>
  
  <hr>
  
  <p>Answer 1: 
  I have tried to put in button Action the following code:</p>
  
  <pre><code>[self.navigationController popToRootViewControllerAnimated:NO]; 
  
   do some stuff here to prepare for the push.
  
  [self.navigationController pushViewController:self.myOtherController animated:YES];
  </code></pre>
  
  <p>but it only pops to the roorController. It doesn't push the other viewController I want.</p>