在导航控制器中单击后退按钮时调用哪个方法? [英] Which method is called when back button clicked in navigation controller?
本文介绍了在导航控制器中单击后退按钮时调用哪个方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在导航控制器中单击后退按钮时保存数据库.
I want to save DB when the back button clicked in navigation controller.
所以我会在方法中插入代码.
so I would insert code in method.
在导航控制器中点击后退按钮会调用什么方法?
What method is called when back button clicked in navigation controller?
推荐答案
做你问的,看UINavigationControllerDelegate
协议,即方法:
To do what you asked, look at the UINavigationControllerDelegate
protocol, namely the method:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
当 viewController 参数不再是你的视图控制器时,你应该保存.
when the viewController argument is no longer your view controller then you should save.
然而,在 viewWillDisappear:
上这样做可能是一个更好(也更简单)的想法.
However, doing so on viewWillDisappear:
might be a better (and much simpler) idea.
这篇关于在导航控制器中单击后退按钮时调用哪个方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文