viewDidAppear在加载

viewDidAppear在加载

本文介绍了iPhone viewDidAppear在加载/关闭模式视图后停止触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始对此感到疯狂.

我有一个iPhone应用程序,它的视图结构有些复杂,它是一个选项卡式应用程序,每个选项卡上都有一个视图控制器或导航控制器.

I have an iphone application with a somewhat complex view structure it is a tabbed application with either a view controller or a navigation controller on each tab.

一个选项卡的主控制器使用viewDidAppear回调重新加载自上次显示以来已修改的所有数据,在大多数情况下,此方法运行良好.我遇到的问题是,当我使用标准导航控制器推入/弹出机制在子视图(在同一标签内)中导航时,当我导航回主视图时,主视图上的viewWillAppear和viewDidAppear始终会触发.但是,如果我加载模态视图控制器然后将其关闭,则viewWillAppear继续触发,但viewDidAppear停止触发.

The main controller for one tab uses the viewDidAppear callback to reload any data that has been modified since the last time it was displayed and this behaves fine in most cases. The issue I have run into is that when I navigate in subviews(within the same tab) using the standard navigation controller push/pop mechanism the viewWillAppear and viewDidAppear on the main view always fire when I navigate back to it.However if I load a modal view controller and then dismiss it, the viewWillAppear continues to fire but the viewDidAppear stops firing.

我几乎可以肯定,这与在模态控制器上手动调用这些回调的需求有关,但是我找不到有关如何正确执行此操作的参考信息.(我只在硬件上看到此viewDidAppear错误,在模拟器中它按预期运行)

I am almost certain that this is tied to the need to manually call these callbacks on the modal controller but I cannot find the reference info on how to do this correctly. (I only see this viewDidAppear bug on the hardware, in the simulator it works as I'd expect)

如果您需要进一步的澄清,请让我知道并感谢您的投入.

If you need further clarification let me know and thanks for any input.

推荐答案

是的,这就是它的工作原理.最好切换到使用viewWillAppear.

Yes, this is how it works. You are better off switching to using viewWillAppear.

这具有在重绘屏幕之前更新数据的附加优势.

This has the added advantage of updating the data before the screen is redrawn.

这篇关于iPhone viewDidAppear在加载/关闭模式视图后停止触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 03:59