applicationWillTerminate

applicationWillTerminate

在iOS 4.0中未调用applicationWillTerminate委托(delegate)方法
当我按下Home按钮时,我看到applicationWillResignActive和applicationDidEnterBackground委托(delegate)方法被调用。

 - (void)applicationWillResignActive:(UIApplication *)application
{
  NSLog(@"Application Did Resign Active");
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
  NSLog(@"Application Did Enter Background");
}

当我双击Home按钮并再次启动Application时,我发现正在调用applicationWillEnterForeground和applicationDidBecomeActive委托(delegate)方法。
 - (void)applicationWillEnterForeground:(UIApplication *)application
{
  NSLog(@"Application Will Enter Foreground");
}



- (void)applicationDidBecomeActive:(UIApplication *)application
{
  NSLog(@"Application Did Become Active");
}

但是我想知道何时调用applicationWillTerminate委托(delegate)方法,在这里我执行一些数据库/文件备份例程。
- (void)applicationWillTerminate:(UIApplication *)application{

}

我什至尝试点击减号并删除了在后台运行的应用程序,但仍未调用任何委托(delegate)方法。

有任何想法吗 ???

最佳答案

从《 iPhone应用程序编程指南》中:



因此,是的,在iOS 4中通常不会经常调用applicationWillTerminate:。如果必须保存数据,则应同时在applicationWillTerminate:applicationDidEnterBackground:中进行保存。

10-08 18:55