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:
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.
to do so, i react upon calls to - (void)applicationWillResignActive:(UIApplication *)application
in my AppDelegate.
that does the job quite well BUT
- if the user double-taps th开发者_JS百科e home icon to open the task switcher the tableview gets faded out as well
- the same thing happens if the iphone locks the screen automatically
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?
Thanks for your help
*samSam,
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.
On the other hand, I think you what you are wanting is applicationDidEnterBackground:
instead of applicationWillResignActive:
.
精彩评论