判断在UIViewController中,viewWillDisappear的时候是push还是pop出来

from: http://blog.csdn.net/linkai5696/article/details/5700734

- (void)viewWillDisappear:(BOOL)animated { 

  NSArray *viewControllers = self.navigationController.viewControllers; 
  if (viewControllers.count > 1 && [viewControllers objectAtIndex:viewControllers.count-2] == self) { 
    // View is disappearing because a new view controller was pushed onto the stack  
    NSLog(@"New view controller was pushed"); 
  } else if ([viewControllers indexOfObject:self] == NSNotFound) { 
    // View is disappearing because it was popped from the stack 
    NSLog(@"View controller was popped"); 
  } 
}

你可能感兴趣的:(判断在UIViewController中,viewWillDisappear的时候是push还是pop出来)