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");
网友评论