- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
什么情况下会调用applicationWillTerminate?例如,如果代码发生崩溃,是否会偶尔调用它?
Apple 的文档对此含糊不清,它只说明系统何时因某种原因需要终止它。
For apps that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the app. For apps that support background execution, this method is generally not called when the user quits the app because the app simply moves to the background in that case. However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason.
最佳答案
我刚刚探讨了这个问题(iOS 9.2)。我已经得到了一些结果。
因此,当用户终止应用程序而不将其切换到后台模式时,将调用 applicationWillTerminate
:应用程序处于事件状态,用户双击主页按钮并退出应用程序。
但是如果用户首先将应用程序切换到后台,然后在此之后尝试终止应用程序,则不会调用 applicationWillTerminate
。
你可以检查这个:
- (void)applicationWillTerminate:(UIApplication *)application {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"term"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
和
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"term"]){
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"term"];
[[NSUserDefaults standardUserDefaults] synchronize];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"WORKED" message:@"term works" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
[alert show];
}
...
return YES;
关于ios - 什么时候调用 applicationWillTerminate?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29416375/
我正在尝试在应用程序终止之前发布一些数据。我通过使用 CFStreamCreatePairWithSocketToCFHost 生成套接字来做到这一点,稍后我有用于读取和写入的回调。 但我无法发布任何
当我的应用程序在 iPhone 模拟器中运行时,委托(delegate)方法 - (void)applicationWillTerminate:(UIApplication *)application
我的应用程序中有一些单独的线程需要正确拆除。如果用户在文件菜单中选择退出菜单项,我会抛出一个错误,提示...请在退出之前停止您正在执行的其他操作。但是,如果用户从 Mac 上的应用程序底座退出该应用程
我实现了 applicationWillTerminate 方法,但它从未被调用 -(void)applicationWillTerminate:(NSNotification *)notificat
无法弄清楚应用终止时会发生什么。 查看 applicationWillTerminate 的苹果文档说: 对于不支持后台执行或链接到 iOS 3.x 或更早版本的应用程序,当用户退出应用程序时始终调用
有没有办法判断我的 Android 应用程序何时终止?在 iOS 中,AppDelegate 中有一个方法 - (void)applicationWillTerminate:(UIApplicatio
我有一个应用程序需要知道它何时崩溃(用于调试目的)。当应用程序关闭时,它会在委托(delegate)中调用 - (void)applicationWillTerminate:(UIApplicatio
什么情况下会调用applicationWillTerminate?例如,如果代码发生崩溃,是否会偶尔调用它? Apple 的文档对此含糊不清,它只说明系统何时因某种原因需要终止它。 For apps
当我的应用程序终止时(通过操作系统或双击主页按钮并终止应用程序),我想取消AllLocalNotifications并将ApplicationIconBadgeNumber设置为0。我只是将这两个调用
您好,我已经阅读了几个关于 applicationWillTerminate 被调用和不被调用的问题。 我想总结一下我的理解,因为有几篇文章的说法不同。 对于 IOS(无多任务处理),按下主页按钮时始
我想在终止之前保存数据,因此我的 AppControll 类符合 NSApplicationDelegate 协议(protocol),并声明了该方法;在界面生成器中,我将窗口的委托(delegate
我正在尝试在 AppDelegate 的 applicationWillTerminate 中发出套接字事件。我使用过socket.io。 我相信我能够成功发出该事件。以下是我在控制台中收到的日志:
我目前正在构建一个支持后台模式的应用程序。仅举几例,我已注册 HealthKit 的后台传送,并且还监视 didEnterRegion 等位置后台事件。据我所知,如果调用这些,iOS 将暂时在后台重新
我正在尝试从加载到 applicationWillTerminate 的 View 中保存我的数据,但遇到了一些问题。 我有四种看法:在 FinateViewController 中FirestVie
我在 Apple 的 iOS 开发中心进行了搜索,但找不到任何合适的东西。这是我的问题: 我有一个将 CoreData 与多个实体一起使用的应用程序。数据通过服务器动态更新。现在,每次应用激活时都会调
有没有办法保证 AppDelegate 委托(delegate)中的 applicationWillTerminate 方法会被命中?像 info.plist 文件中的 key 之类的东西......
在我的应用程序中,当用户终止应用程序时,我需要向服务器发送一些指令。在 applicationWillTerminate func 中,我尝试发送它,但它从未到达服务器。我尝试使用 Alamofire
我想在 iOS 设备上插入时启动我的应用程序,但我找不到任何解决方案,我该怎么做。我想知道,Apple 是否允许在 applicationWillTerminate 函数中启动应用程序? 感谢您的关注
我们知道,当app被杀死时,在AppDelegate中,系统会调用applicationWillTerminate:方法。 但是你知道,如果 archive 是一个 singleton,这是一个非常重
这个问题在这里已经有了答案: When an app crashes does either the 'applicationWillTerminate' or 'applicationDidEnt
我是一名优秀的程序员,十分优秀!