title: UINavigationController: How to cancel the back button event?
body: <p>In my <code>UIViewController</code> I have a <code>UINavigationController</code> with a default back button. When the user clicks the back button, a warning message should appear: "Do you really want to go back?". I know, that it is not possible to trap the back button event. It's only possible the use <code>viewWillDisappear</code> and set a flag:</p>
  
  <pre><code>- (void)viewWillDisappear:(BOOL)animated {
      if (backBtnPressed) {
          UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Question" message:@"Do you really want to go back?" delegate:self cancelButtonTitle:@"No" otherButtonTitles: @"Yes", nil] autorelease];
          [alert show];   
      }
  }
  
  - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
      if (buttonIndex == 0) {
          // don't go back!
          // cancel the back button event
      }
      else if (buttonIndex == 1) {
          // go back
      }
  }
  </code></pre>
  
  <p>But with this code I have no chance! I can't stop the back button event, isn't it?</p>
  
  <p>Do I have to write my own back button and set it as <code>leftBarButtonItem</code>? Or is there anybody with a great idea? :-)</p>
  
  <p>Thanks for your help!</p>