开发者

Exiting or interrupted?

开发者 https://www.devze.com 2023-01-18 23:43 出处:网络
Is there a way to differentiate when a user is exiting an app because he/she pressed the home button or because it\'s rece开发者_Go百科iving a phone call?in iOS 4.0 the app doesn\'t quit if the user a

Is there a way to differentiate when a user is exiting an app because he/she pressed the home button or because it's rece开发者_Go百科iving a phone call? in iOS 4.0 the app doesn't quit if the user answers a call but it does in 3.x.

I'd like to save my app state if the user is interrupted by a call or any other phone event but not if the user exits the app by pressing the home button.

Any advice??


The following application delegate methods get called in different situations:

  • applicationWillTerminate - user pressed "home" button and application is about to exit

  • applicationWillResignActive - user got incoming call or sms alert. if he decides to accept the call the application will quit

  • applicationDidBecomeActive - user ignored incoming call

  • applicationDidEnterBackground - user pressed "home" button and application went to background mode - applicable for platforms that support multitasking

So it seems you need to use applicationWillResignActive: method in app delegate to distinguish between your two cases

0

精彩评论

暂无评论...
验证码 换一张
取 消