简体   繁体   English

按下后退按钮时保存和还原UIViewcontroller

[英]Save and Restore UIViewcontroller when back button is pressed

I have two UIViewControllers . 我有两个UIViewControllers In first UIViewController I have a UITableView as a subview. 在第一个UIViewController我有一个UITableView作为子视图。 When any one of the UITableViewCell is selected, a UIView (as a subview) will be displayed, which have 9 buttons. 选择任何一个UITableViewCell ,将显示一个UIView (作为子视图),它具有9个按钮。 When any one of the button is pressed, Second UIViewController will be presented. 当按下任一按钮时,将显示Second UIViewController When user press custom back button on second UIViewController , First UIViewController have to be presented with all previous selected UITableViewCell and corresponding subviews open. 当用户按下第二个UIViewController上的自定义后退按钮时,必须在所有先前选择的UITableViewCell和对应的子视图打开的情况下显示第一个UIViewController How to achieve this. 如何实现这一目标。 Is there any process to save UIViewController's state at a desired time. 是否有任何过程可以在所需的时间保存UIViewController's状态。

Any suggestion will be greatly appreciated. 任何建议将不胜感激。

If your are using a Navigation controller, navigating from one controller to another, your parent view controller will not be deallocated. 如果您使用的是导航控制器,则从一个控制器导航到另一个控制器,则不会取消分配父视图控制器。 Hence you can maintain state of that first view controller by means of properties or something else. 因此,您可以通过属性或其他方式维护该第一个视图控制器的状态。 When viewWillAppear is called for that controller, you can make use of that and update the controller accordingly. 为该控制器调用viewWillAppear时,您可以使用该控制器并相应地更新该控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM