检查UIViewController是否即将从导航堆栈中弹出? [英] Checking if a UIViewController is about to get Popped from a navigation stack?

查看:88
本文介绍了检查UIViewController是否即将从导航堆栈中弹出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道我的视图控制器何时会从导航堆栈弹出,以便我可以执行操作。

I need to know when my view controller is about to get popped from a nav stack so I can perform an action.

我无法使用-viewWillDisappear,因为当视图控制器由于任何原因而被移出屏幕时会被调用(比如新的视图控制器被推到顶部)。

I can't use -viewWillDisappear, because that gets called when the view controller is moved off screen for ANY reason (like a new view controller being pushed on top).

我特别需要知道控制器何时即将被弹出。

I specifically need to know when the controller is about to be popped itself.

任何想法都会很棒,提前谢谢。

Any ideas would be awesome, thanks in advance.

推荐答案

我认为没有明确的消息,但你可以继承UINavigationController并覆盖 - popViewControllerAnimated(尽管我之前没有尝试过这个)。

I don't think there is an explicit message for this, but you could subclass the UINavigationController and override - popViewControllerAnimated (although I haven't tried this before myself).

或者,如果没有对视图控制器的其他引用,你可以添加到它 - dealloc吗?

Alternatively, if there are no other references to the view controller, could you add to its - dealloc?

这篇关于检查UIViewController是否即将从导航堆栈中弹出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆