iPhone - 如何保存每个视图控制器?
当我的应用程序的“applicationWillTerminate”函数在应用程序的委托文件中被调用时,我需要循环遍历选项卡控制器的每个子控制器并保存其当前状态。是否可以循环遍历每个 viewController 调用自定义保存函数?
When my app's “applicationWillTerminate” function is called in the app’s delegate file I need to loop through each child controller of a tab controller and save the current state it is in. Is it possible to loop through each viewController calling a custom save function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
获取
tabBarController.viewControllers
并将makeObjectsPerformSelector:@selector(yourCustomSaveMethod)
消息发送到该数组。Get the
tabBarController.viewControllers
and send themakeObjectsPerformSelector:@selector(yourCustomSaveMethod)
message to that array.查看
UIApplicationWillTerminateNotification
和UIApplicationDidEnterBackgroundNotification
。比循环视图控制器要好得多。Have a look at
UIApplicationWillTerminateNotification
andUIApplicationDidEnterBackgroundNotification
. Much nicer than looping through your view controllers.