如何将方法添加到 UINavigationbar 后退按钮,所以每当我单击该后退按钮时,我需要检查一些值并显示 UIAlertView?有什么选择吗?
我尝试了这种方法,但它对我有用
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
//show alert
}
还有这种方法,但两者都没有醒来
-(void) viewWillDisappear:(BOOL)animated {
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
// back button was pressed. We know this is true because self is no longer
// in the navigation stack.
NSLog(@"hi");
}