推荐你看看UIApplicationDelegate
。有许多有趣的委托方法来处理您的应用程序状态。当然,您可以在任何 ViewController 中实现这些方法。让我们看看那里。
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
你的问题:
当有人终止应用程序(不是点击“主页”按钮,而是从字面上关闭应用程序在后台运行)时,是否有终止用户会话并将其注销?
当然,您可以实现清除用户会话并将其注销的方法(如果您以单一模式执行,那么在任何 ViewController 中处理这些情况都会很棒)
同样,一旦我弄清楚这一点,如果应用程序仍在其设备的后台运行并且尚未完全终止,是否无论如何都不会调出我的登录视图控制器?
您应该处理我在此处的其他 StackOverflow 问题中的回答的 3 个步骤。
您还可以在UIApplicationDelegate 协议参考中看到有用的信息。