title: Duplicate UIViewControllers on UINavigationController stack after application wakes
body: <p>I just learnt IOS programming and am writing my first iPhone app. </p>
  
  <p>My app provides info on an MKMapView, the view controller of which is the root view controller of a UINavigationController. If the mobile signal is bad  i use mapViewDidFailLoadingMap:withError: to make the app push one of two different view controllers onto the navigation controller stack depending on what the user is doing. Code follows:</p>
  
  <pre><code>    - (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error
      {
          NSLog(@"mapViewDidFailLoadingMap: %@", [error localizedDescription]);
          [aiView stopAnimating];
  
          if (mapTypeInt == 0) {
              NSString *message = 
      [NSString stringWithFormat:@"Your signal is not currently 
       strong enough to download a map. Switching to table view."];
              UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Maps Unavailable"
                                                           message:message
                                                          delegate:nil
                                                 cancelButtonTitle:@"OK"
                                                 otherButtonTitles:nil];
              [av show];
              if (currentMode == @"retracingSteps")
              {
                  RetraceViewController *rvc = 
      [[RetraceViewController alloc] initWithNibName:@"RetraceViewController" bundle:nil];
                  [[self navigationController] pushViewController:rvc animated:YES];
              }
              else{
                  TripTableViewController *ttvc = [[TripTableViewController alloc] init];
                  [[self navigationController] pushViewController:ttvc animated:YES];
              }
          }
          else{
              [self setMapType:0];
  
              NSString *message = [NSString stringWithFormat:
      @"Your signal is not currently strong enough to download a satellite map. 
      Switching to Standard Map view."];
              UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Can't Use Satellite Maps"
                                                           message:message
                                                          delegate:nil
                                                 cancelButtonTitle:@"OK"
                                                 otherButtonTitles:nil];
              [av show];
          }
  
  
  
      }
  </code></pre>
  
  <p>Yesterday I tested the poor mobile signal in a rural valley and the correct second view controller was pushed onto the stack. What I then noticed when I locked the phone and rechecked the app after a few minutes was that on waking, the root view controller was displayed quickly followed by the view controller I expected.  In effect what this did was to push an identical copy of the second view controller onto the stack. I discovered this when I had to tap the back button half a dozen times to get back to the root view controller.</p>
  
  <p>What I would like the app to do on wake up is to immediately display the view controller that was live when the phone is locked rather than the root view controller. I do not know how to do this.</p>