在呈现 viewController 之后呈现 viewController 会发生什么?

What happens with presenting viewController after it presents a presented viewController?

在呈现 viewController 之后呈现 viewController 会发生什么。它的实例是否继续存在?当它被呈现的 viewController 视图遮挡时,它是否被销毁?如果它被破坏了,我如何告诉系统不要破坏它,而是保持它完好无损?

我正在 中设计一款游戏,当点击某个按钮时,游戏会被呈现的 viewController 遮挡。当玩家 returns 进入游戏时,我希望它完全恢复到呈现 viewController

之前的状态

呈现的视图控制器保留它的实例,并且在呈现的视图控制器被关闭后将控制返回给它。事实上,如果可能的话,你应该有呈现视图控制器dismiss the presented controller

由于 UIViewControllers 的实例在呈现(或推送)另一个视图控制器时保持完整,最佳做法是在 UIViewControllers 中实施 didReceiveMemoryWarning 方法以释放您可以释放的任何内存(清除缓存等) ).您清除的任何数据可能需要在 viewWillAppear 方法中重新填充。

来自 View Controller Programming Guide for iOS 的其他信息:

Support for presenting view controllers is built in to the UIViewController class and is available to all view controller objects. You can present any view controller from any other view controller, although UIKit might reroute the request to a different view controller. Presenting a view controller creates a relationship between the original view controller, known as the presenting view controller, and the new view controller to be displayed, known as the presented view controller. This relationship forms part of the view controller hierarchy and remains in place until the presented view controller is dismissed.