我建議你看看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中查看有用的信息。