美文网首页
iOS 判断程序在前台还是后台运行

iOS 判断程序在前台还是后台运行

作者: 小柴2011 | 来源:发表于2017-08-01 15:44 被阅读1053次

    UIApplicationState state = [UIApplication sharedApplication].applicationState;

    BOOL result = (state ==UIApplicationStateBackground);

    NSLog(@"是后台运行: %@",result?@"YES":@"NO");

    UIApplicationState state2 = [UIApplication sharedApplication].applicationState;  

    BOOL result2 = (state2 ==UIApplicationStateActive);

    NSLog(@"是前台运行: %@",result2?@"YES":@"NO");

    相关文章

      网友评论

          本文标题:iOS 判断程序在前台还是后台运行

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