Method 1: Write the monitoring event in dealloc, because only pop will call dealloc, and push will not be used
- (void)dealloc {YLLog(@"123"); }
Method 2: Called in - (void)viewWillDisappear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated{
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
NSLog(@"clicked navigationbar back button");
}
}
Method 3: Rewrite the back button, and then call the method of the back button: such as
- (void)popViewcontrollerFunc {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"Are you sure you want to give up the prize you got?" delegate:self cancelButtonTitle:@"I made a mistake" otherButtonTitles:@"Give up hard", nil];alert.tag = 10001;[alert show];
}