title: iPhone: How do I override the back button in a Navigation Controller?
body: <p>In my app I have a basic Navigation Controller.  For all of my views, except one, the controller works as it should.</p>
  
  <p>However, for one view in particular, I would like the 'back' button to not go back to the previous view, but to go to one I set. In particular it is going to go back 2 views and skip over one.</p>
  
  <p>After doing some research I found that I can intercept the view when it disappears, so I tried to put in code to have it navigate to the page I would like:</p>
  
  <pre><code>- (void)viewWillDisappear:(BOOL)animated {
  [super viewWillDisappear:animated];
  //i set a flag to know that the back button was pressed
  if (viewPushed) {
      viewPushed = NO;   
  } else {
      // Here, you know that back button was pressed
      mainMenu *mainViewController = [[mainMenu alloc] initWithNibName:@"mainMenu" bundle:nil];
      [self.navigationController pushViewController:mainViewController animated:YES];
      [mainViewController release];
  }   
  </code></pre>
  
  <p>}</p>
  
  <p>That didn't work, so does anyone have any ideas?</p>
  
  <p>Thanks!!</p>