“终止”之间的区别一个应用程序,打开“任务切换器”和“自动锁定” [英] Difference between "terminating" an app , opening the "task switcher" and "auto lock"
问题描述
我知道这个帖子的标题是不合标准的。
无论如何,这是我面临的问题:
I'm aware of the fact that the title of this thread is substandard. Anyhow, here's the issue I'm facing:
我的应用程序显示一个包含时间相关内容的tableView(内容可以旧),因此更新定期通过调用Web服务并解析其xml答案。
My App displays a tableView with time-relevant content (content can get "old") and therefor updates on a regular basis by calling a web service and parsing its xml answer.
因此,为了不向用户显示过时信息,我想要应用程序进入非活动状态后,隐藏表格并显示正在加载内容标签。
so, in order to not display "out of date" information to the user, i want to hide the table and display a "content is being loaded"-label as soon as the app enters an inactive state.
这样做,我对<$的电话做出反应c $ c> - (void)applicationWillResignActive :( UIApplication *)应用程序在我的AppDelegate中。
to do so, i react upon calls to - (void)applicationWillResignActive:(UIApplication *)application
in my AppDelegate.
能很好地完成工作但是
- 如果用户双击主页图标以打开任务切换器,则tableview也会逐渐消失
- 如果iphone自动锁定屏幕也会发生同样的事情
所以,有没有办法区分非活动状态的类型说明应用程序进入或任何其他方式向我提供pos以不同方式处理这三种状态变化的可能性?或者我需要走在一条完全不同的道路上吗?
so, is there a way to distinguish the "type" of inactive state the app enters or any other means to provide me with the possibility to handle those three state-changes differently? Or do I need to walk on a completely different path here?
感谢您的帮助
* sam
Thanks for your help
*sam
推荐答案
Sam,
我会稍微改变你的问题。每次从Web服务更新数据时,我要做的是将 NSDate
保存到 NSUserDefaults
。然后每当你的 AppDelegate
中的 - (void)applicationDidBecomeActive:(UIApplication *)应用程序
方法被调用时,只需比较存储的 NSDate
到当前时间戳( [NSDate date]
)并且如果差异大于刷新超时隐藏的时间tableView并重新加载数据。
I would go at your problem a little differently. What I would do is save an NSDate
to NSUserDefaults
every time you update your data from the web service. Then whenever your - (void)applicationDidBecomeActive:(UIApplication *)application
method in your AppDelegate
is called just compare that stored NSDate
to the current timestamp ([NSDate date]
) and if the difference is greater than whatever your refresh timeout hide the tableView and reload the data.
另一方面,我认为你想要的是 applicationDidEnterBackground:
而不是 applicationWillResignActive:
。
On the other hand, I think you what you are wanting is applicationDidEnterBackground:
instead of applicationWillResignActive:
.
这篇关于“终止”之间的区别一个应用程序,打开“任务切换器”和“自动锁定”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!