我建议你看看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问题here。
您还可以在UIApplicationDelegate Protocol Reference中查看有用的信息。