iOS开发_判断应用在前台还是后台
1、UIApplicationState 枚举判断应用的状态
typedef NS_ENUM(NSInteger, UIApplicationState) {
UIApplicationStateActive, // 应用处于活跃状态
UIApplicationStateInactive, // 应用处于非活跃状态
UIApplicationStateBackground // 应用处于后台
} NS_ENUM_AVAILABLE_IOS(4_0);
2、实例代码
UIApplicationState state = [UIApplication sharedApplication].applicationState;
if (state != UIApplicationStateBackground) {
CHLog(@"应用在前台")
}