美文网首页
iOS 监测程序被杀死

iOS 监测程序被杀死

作者: 周无恋 | 来源:发表于2019-10-10 09:22 被阅读0次

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"UIApplicationDidEnterBackgroundNotification" object:nil]

    • (void)applicationWillTerminate:(UIApplication *)application {
      // 业务逻辑
      }

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(comeHome:) name:@"UIApplicationDidEnterBackgroundNotification" object:nil];

    • (void)comeHome:(UIApplication *)application {
      NSLog(@"进入后台");
      }

    • (void)applicationWillTerminate:(UIApplication *)application {
      NSLog(@"程序被杀死");
      }

    • (void)applicationWillTerminate:(UIApplication *)application {
      NSLog(@"程序被杀死");
      }
      写上你的本地通知方法

    最后,希望这篇文章能帮到你。

    相关文章

      网友评论

          本文标题:iOS 监测程序被杀死

          本文链接:https://www.haomeiwen.com/subject/byjfcxtx.html