Iphone 如何知道一个应用程序何时接近跳板

Iphone 如何知道一个应用程序何时接近跳板,iphone,objective-c,ipad,Iphone,Objective C,Ipad,我想捕捉一个应用程序何时从springboard关闭以进行一次注销。但是applicationWillTerminate方法不起作用 有人知道这件事吗 谢谢当你说关闭时,你的意思是:当一个应用程序从最近使用的工具栏关闭时(双击主页按钮) 你无法检测到用户何时像那样关闭你的应用程序,因为操作系统会杀死你的应用程序。此未关闭和on close方法正在被调用。当您说closed时,您的意思是:当应用程序从最近使用的工具栏关闭时(双击home按钮) 你无法检测到用户何时像那样关闭你的应用程序,因为操作系

我想捕捉一个应用程序何时从springboard关闭以进行一次注销。但是applicationWillTerminate方法不起作用

有人知道这件事吗


谢谢当你说关闭时,你的意思是:当一个应用程序从最近使用的工具栏关闭时(双击主页按钮)


你无法检测到用户何时像那样关闭你的应用程序,因为操作系统会杀死你的应用程序。此未关闭和on close方法正在被调用。

当您说closed时,您的意思是:当应用程序从最近使用的工具栏关闭时(双击home按钮)


你无法检测到用户何时像那样关闭你的应用程序,因为操作系统会杀死你的应用程序。此方法未关闭,正在调用on close方法。

我认为,您应该执行以下方法一次

- (void)applicationWillResignActive:(UIApplication *)application
{
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     */
}
您放置在
应用程序中的代码将终止
,请将其放入上述方法中。
尝试将您的代码放在其中一个方法中&检查您的逻辑是否工作

编辑

问题指定要检测应用程序强制退出事件-这是不可能的。(对不起,但不是在我手中)


我们通过双击从最小化状态删除应用程序的方式—实际上,这意味着我们正在强制退出这些应用程序&这不会触发我们的任何应用程序方法,因为我们的应用程序进程将被终止。

我相信,您应该执行以下方法一次

- (void)applicationWillResignActive:(UIApplication *)application
{
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     */
}
您放置在
应用程序中的代码将终止
,请将其放入上述方法中。
尝试将您的代码放在其中一个方法中&检查您的逻辑是否工作

编辑

问题指定要检测应用程序强制退出事件-这是不可能的。(对不起,但不是在我手中)


我们通过双击从最小化状态删除应用程序的方式—实际上,这意味着我们正在强制退出这些应用程序&这不会触发我们的任何应用程序方法,因为我们的应用程序进程将被终止。

当您按home按钮时,应用程序不会退出/退出。它只是进入背景。因此,不会调用applicationWillTerminate

按两次home按钮以验证应用程序是否已关闭


同时计算Spark的答案当您按下home(主页)按钮时,应用程序不会退出。它只是进入背景。因此,不会调用applicationWillTerminate

按两次home按钮以验证应用程序是否已关闭


还认为Spark的答案是“从跳板关闭”吗?意味着,是否要捕获从后台运行应用程序关闭应用程序?“从springboard关闭”?意思是,你想从后台运行的应用程序中捕获关闭应用程序的过程吗?谢谢,你确定在这种情况下没有调用该方法吗?谢谢,你确定在这种情况下没有调用该方法吗?是的,我知道,但我想在你按下两次“主页”按钮关闭应用程序时获取是的,我知道,但我想知道你关闭应用程序时按下两次home(主页)按钮的时间谢谢,但我想知道你关闭应用程序的时间。@damacri86-然后你应该使用
applicationWillResignActive
-这将立即触发。再次感谢@Spark,但在从springboard关闭应用程序时不会调用它:(@damacri86-我们通过双击从最小化状态删除应用程序的方式-实际上意味着,我们正在强制退出这些应用程序&这不会触发我们的任何应用程序方法,因为我们的应用程序进程将被终止。谢谢你,但我想知道你关闭应用程序的瞬间。@damacri86-那么你应该使用
 applicationWillResignActive
-这将立即触发。再次感谢@Spark,但当应用程序从springboard关闭时,不会调用它:(@damacri86——我们通过双击从最小化状态删除应用程序的方式——实际上意味着,我们正在强制退出这些应用程序&这不会触发我们的任何应用程序方法,因为我们的应用程序进程将被终止。