攔截iOS系統導航欄返回按鈕事件-三種方法


方法一:在dealloc里面書寫監聽事件,因為只有pop才會調用dealloc,push不會掉用

- (void)dealloc {YLLog(@"123"); }

方法二:在- (void)viewWillDisappear:(BOOL)animated中調用

- (void)viewWillDisappear:(BOOL)animated{

  if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {

    NSLog(@"clicked navigationbar back button");

  }

}

方法三:重寫返回按鈕,然后調用返回按鈕的方法即可:如

- (void)popViewcontrollerFunc {

  UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"確定要放棄到手的獎品嗎" delegate:self cancelButtonTitle:@"點錯啦" otherButtonTitles:@"狠心放棄", nil];alert.tag = 10001;[alert show];

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM