iOS导航控制器中的后退按钮回调 [英] back button callback in navigationController in iOS
本文介绍了iOS导航控制器中的后退按钮回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将视图推送到导航控制器上,当我按下后退按钮时,它会自动转到上一个视图.在从堆栈中弹出视图之前按下后退按钮时,我想做一些事情.返回按钮回调函数是哪个?
I have pushed a view onto the navigation controller and when I press the back button it goes to the previous view automatically. I want to do a few things when back button is pressed before popping the view off the stack. Which is the back button callback function?
推荐答案
William Jockusch 的 answer 用简单的技巧解决了这个问题.
William Jockusch's answer solve this problem with easy trick.
-(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.
}
[super viewWillDisappear:animated];
}
这篇关于iOS导航控制器中的后退按钮回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文