2013-02-07 62 views
2

是否有任何解決方案來區分手動退出應用程序(通過主頁按鈕單擊)和通過來電退出應用程序?區分主頁按鈕點擊和來電ios?

請幫忙!!!

+0

wt你想要????和wt是你的問題? – iPatel

+0

我的問題是運行應用程序時,如果我收到一個電話並收到它,那麼應用程序將進入後臺模式。如果通話沒有收到,它的工作正常。 所以我的問題是我不得不區分當應用程序進入背景模式在以下兩種情況: 1.When手動退出應用程序的主頁按鈕單擊。 2.接到電話。 – silentBeep

回答

2

是的,有點。

單擊主頁按鈕或關閉屏幕將導致您的應用程序被置於後臺(applicationDidEnterBackground),而電話不會,並且只會讓您的應用程序退出其活動狀態(applicationWillResignActive)。

但是,其他操作(例如提高多任務欄)也會導致您的應用程序退出。

+0

+1給你,你比我快20秒;-) –

+0

幸運我;)謝謝! – borrrden

0

您無法處理主頁按鈕單擊。但當用戶點擊主頁按鈕或點擊應用程序圖標代表方法應用程序被調用。你可以編寫代碼。

- (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 inactive 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:. 
*/ 
} 

它可以幫助你解決旅遊問題。