在viewWillDisappear方法可以检查值isMovingFromParentViewController:
self.isMovingFromParentViewController()
它将返回Bool,它是一个布尔值,指示视图控制器正在从其父项中移除。
更新时间:
作为回答,我想你会需要自定义的执行回用自己的方法按钮,可以跟踪它。
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.hidesBackButton = true;
let backButton = UIBarButtonItem(title: "< Back", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
backButton.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Chalkduster", size: 20)!], forState: UIControlState.Normal)
navigationItem.backBarButtonItem = backButton
backButton.addTarget(self, action: "backButtonMethod",forControlEvents:UIControlEvents.TouchUpInside)
[检测当按下一个导航栏的“返回”按钮]的可能的复制(http://stackoverflow.com/questions/8228411/detecting-when-the-back-button-is-pressed- on-a-navbar) –
嗨。这不是这个问题的重复,因为我试图找出哪个事件被调用,而不是视图控制器被解雇的地方 – Lneuner
@Lneuner viewDidDisappear:和viewWillDisappear是视图消失时调用的方法 – Smile