【发布时间】:2013-08-02 00:55:45
【问题描述】:
目前,我按以下方式设置了导航堆栈:
ViewController A -> ViewController B -> ViewController C -> ViewController D
在ViewController C 和ViewController D 的实现代码中,我有一个选择器,只有在满足以下测试时才会运行代码块
if (self.navigationController.visibleViewController)
我面临的问题是上述测试对于ViewController C 总是返回true。首先,我在 IOS 模拟器中启动我的应用程序,然后向上导航到 View Controller D。一旦ViewController D 加载,我按下模拟器上的“主页”按钮。按下主页按钮后,我再次单击我的应用程序并重新启动我的应用程序(进入前台)。现在发生的事情很奇怪,我可见的视图控制器是ViewController D,因为那是我上次使用的视图控制器。尽管ViewController D 现在是我目前唯一可见的视图控制器,但上面的 if 语句对于ViewController C 也返回 true! (我只希望ViewController D's选择器代码被执行,这是个问题)。
所以这引出了一个问题,成为visibleViewController 到底意味着什么?如果ViewController D 是出现在我面前的视图控制器,我怎样才能使ViewController C's 选择器不执行。谢谢!
【问题讨论】:
标签: iphone ios objective-c uinavigationcontroller