从后台删除后保存应用程序状态
我在我的应用程序委托中使用以下函数
- (void)applicationWillResignActive:(UIApplication *)application {
NSLog(@"applicationWillResignActive");
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSLog(@"applicationDidEnterBackground");
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(@"applicationWillEnterForeground");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(@"applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(UIApplication *)application {
NSLog(@"applicationWillTerminate");
}
所有函数都工作正常。但是当我通过单击后台任务中的“-”红色按钮从后台删除应用程序时,然后再次打开应用程序。没有调用任何函数。我应该使用什么来代替上述所有功能..有什么想法吗?
我到底需要的是..我需要在使用“-”红色按钮从后台删除应用程序状态时保存应用程序状态,并在打开时恢复它。
I am using following functions in my App delegate
- (void)applicationWillResignActive:(UIApplication *)application {
NSLog(@"applicationWillResignActive");
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSLog(@"applicationDidEnterBackground");
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(@"applicationWillEnterForeground");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(@"applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(UIApplication *)application {
NSLog(@"applicationWillTerminate");
}
All functions are working fine. But When i Delete the app from the Background by clicking "-" red button in the background tasks, and again open the app. no function has been called. What should i use instead of all the above functions..have any ideas?
What exactly i need is ..i need to save the application state when it has been deleted from the background using "-" red button and restore it when ever it opened.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当应用程序进入后台模式时,您应该保存应用程序的状态(
-applicationDidEnterBackground
)。当后台应用程序终止时,不会调用委托方法。您应该在 iOS 应用程序编程指南。
You should save the state of the application when it enters background mode (
-applicationDidEnterBackground
). No delegate methods are called when a background app is terminated.You should find a lot of useful informations about this in the iOS Application Programming Guide.