iOS 在当前显示的控制器里如何判断程序是否被杀死?

联系人:石虎 QQ:1224614774昵称: 嗡嘛呢叭咪哄

                   QQ群:807236138 群称:iOS 技术交流学习群

通过添加通知:

一、添加进入后台的判断

[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(sh_comeHome:) name:@"UIApplicationDidEnterBackgroundNotification"object:nil];

- (void)sh_comeHome:(UIApplication *)application {

        NSLog(@“石虎—进入后台");

     }


二、添加程序被杀死的判断

[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(applicationWillTerminate:) name:@"UIApplicationWillTerminateNotification"object:nil];

- (void)applicationWillTerminate:(UIApplication *)application {

       NSLog(@“石虎—程序被杀死");

     }

谢谢!!!

你可能感兴趣的:(iOS 在当前显示的控制器里如何判断程序是否被杀死?)