When waking up i.e. relaunching an app (either through springboard, app switching or URL)applicationWillEnterForeground:
is called. It is only executed once when the app becomes ready for use, after being put into the background, while applicationDidBecomeActive:
may be called multiple times after launch. This makes applicationWillEnterForeground:
ideal for setup that needs to occur just once after relaunch.
applicationWillEnterForeground:
is called:
applicationDidBecomeActive:
applicationDidBecomeActive:
is called:
application:didFinishLaunchingWithOptions:
applicationWillEnterForeground:
if there's no URL to handle.application:handleOpenURL:
is called.applicationWillResignActive:
if user ignores interruption like a phone call or SMS.applicationWillResignActive:
is called:
applicationDidEnterBackground:
is called.applicationDidBecomeActive:
is called.applicationDidEnterBackground:
is called:
applicationWillResignActive:
beginBackgroundTaskWithExpirationHandler:
1.程序启动时触发:一致
iOS4.3与iOS5.0
didFinishLaunchingWithOptions->UIApplicationStateInactive
applicationDidBecomeActive->UIApplicationStateActive
2.锁屏键:不同
Lock:
iOS4.3
applicationWillResignActive->UIApplicationStateActive
iOS5.0
applicationWillResignActive->UIApplicationStateActive
applicationDidEnterBackground->UIApplicationStateInactive
Unlock:
iOS4.3
applicationDidBecomeActive->UIApplicationStateActive
iOS5.0
applicationWillEnterForeground->UIApplicationStateInactive
applicationDidBecomeActive->UIApplicationStateActive
3.单击Home键:一致
进入:
iOS4.3与iOS5.0
applicationWillResignActive->UIApplicationStateActive
applicationDidEnterBackground->UIApplicationStateBackground
返回:
iOS4.3与iOS5.0
applicationWillEnterForeground->UIApplicationStateBackground
applicationDidBecomeActive->UIApplicationStateActive
4.双击Home键:一致
进入:
iOS4.3与iOS5.0
applicationWillResignActive->UIApplicationStateActive
返回:
iOS4.3与iOS5.0
applicationDidBecomeActive->UIApplicationStateActive
5.终结程序时:一致
iOS4.3与iOS5.0
applicationWillResignActive->UIApplicationStateActive
applicationDidEnterBackground->UIApplicationStateBackground