我需要您的帮助来澄清我对应用程序各种状态的理解。我将陈述我的解释 - 但请随时纠正我。
1) 应用程序在前台启动并运行:state = UIApplicationStateActive
2) 用户按下主页按钮:state = UIApplicationStateBackground (????)。
Debug stmt in my app shows it to be Active
3) 用户双击 Home 并终止应用: state = UIApplicationStateInactive
如果 case 2 的值确实是 Active,那么该值何时设置为 Background?
我的基于位置的应用程序依赖此值来为用户采取适当的行动。
if ( ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) ||
([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) ) {
// isInBackground = YES;
// ------ UI not available
}
else {
// isInBackground = NO;
// ------ UI is available
}
问候,山姆。