在导航控制器中单击后退按钮时会调用哪个方法?
我想在导航控制器中单击后退按钮时保存数据库。
所以我会在方法中插入代码。
在导航控制器中单击后退按钮时会调用什么方法?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这不适合使用,但这对我有用。不要忘记设置 UINavaigationController 委托。
Maybe it's not appropriate use, but that worked for me. Don't forget to set UINavaigationController delegate.
要执行您要求的操作,请查看 UINavigationControllerDelegate 协议,即方法:
当 viewController 参数不再是您的视图控制器时,您应该保存。
然而,在
viewWillDisappear:
上这样做可能是一个更好(而且更简单)的想法。To do what you asked, look at the
UINavigationControllerDelegate
protocol, namely the method:when the viewController argument is no longer your view controller then you should save.
However, doing so on
viewWillDisappear:
might be a better (and much simpler) idea.