重新打开应用程序时如何显示相同的视图 [英] how to show the same view when the app is reopened

查看:74
本文介绍了重新打开应用程序时如何显示相同的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表视图,该表视图显示单击表中某行时的网络视图,这反过来又从sqlite中获取数据.如果用户在查看Webview中的描述时按下主键关闭了该应用程序,有时又重新打开了该应用程序,那么我应该让用户看到相同的屏幕.如何再次显示相同的视图?什么是有效的方法?

I have a tableview which shows a webview on clicking some row in the table, which in turn picks up the data from an sqlite. if a user closes the app by pressing home key while viewing a description in webview and reopens it after sometimes, I should be making the user to see the same screen. how to show the same view again ? What is the efficient way ?

推荐答案

好吧,我认为最简单的方法是将应用程序的状态存储在NSUserDefaults中. UIApplication上有一个委托方法,称为:

Well I think the easiest way is to store the state of the application in NSUserDefaults. There is a delegate method on UIApplication called:

- (void)applicationWillTerminate:(UIApplication *)application

当用户退出应用程序时,将调用此委托方法.这是您可以将应用程序状态保存到NSUserDefaults的时间.但是请注意,您不能在那儿做耗时的事情.如果这样做,您将被操作系统杀死.

This delegate method gets called when the user quits the app. This is the time where you can save the state of your application off to the NSUserDefaults. But be aware that you cannot do time intensive stuff there. If you do, you get killed by the OS.

在您的情况下,为什么不简单地存储用户在NSUserDefaults中选择的行,然后签入 -(void)applicationDidFinishLaunching:(UIApplication *)application 如果有已保存的行,请适当地恢复屏幕.

In your case why not simply store the row the user picked in NSUserDefaults and then check in -(void)applicationDidFinishLaunching:(UIApplication *)application if there is a saved row and restore the screen approbiately.

这篇关于重新打开应用程序时如何显示相同的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆