IOS development programs of various states monitor

1, five states program
Not Running: not running.
Inactive: Front inactive. In the foreground, but we can not accept the event handling.
Active: Front active. In the foreground, to accept event handling.
Background: Background state. Into the background, but also if the executing code, executes the code, code execution is completed, the program hangs.
Suspended: a suspended state. Into the background, you can not execute code, if insufficient memory, the program will be killed.

2, callback methods and notification AppDelegate in
(1) callback method: application: didFinishLaunchingWithOptions:
         local notifications: UIApplicationDidFinishLaunchingNotification
         after the program started and initialized when: Trigger timing.
        Suitable operation: this stage should be to create the root view.
(2) callback method: applicationDidBecomeActive:
         local notifications: UIApplicationDidBecomeActiveNotification
        Trigger timing: the program into the foreground and active when you call.
        Suitable operation: This phase should restore UI state (such as state of the game).
(3) callback method: applicationWillResignActive:
         local notifications: UIApplicationWillResignActiveNotification
        Trigger timing: enter an inactive state from the active state.
        Suitable operation: This phase should save UI state (such as state of the game).
 (4) callback method: applicationDidEnterBackground:

         Local notifications: UIApplicationDidEnterBackgroundNotification
        Trigger timing: when to call the program into the background.
         Suitable operation: This phase should save user data, free up some resources (such as the release database resources).
(5) callback method: applicationWillEnterForeground:
         local notifications: UIApplicationWillEnterForegroundNotification
        call the program into the foreground, but not yet active: Trigger timing.
         Suitable operation: This phase should restore user data.
(6) callback method: applicationWillTerminate:
         local notifications: UIApplicationWillTerminateNotification
        Trigger timing: Called when the program is killed.
         Suitable operation: This phase should free up some resources and save user data.
 
 3, the program starts
when you click the application icon, will go through three states:
Not running -> Inactive -> the Active 

Not running -> Inactive
calling application: didFinishLaunchingWithOptions: Send: UIApplicationDidFinishLaunchingNotification 
Inactive -> the Active  


Call applicationDidBecomeActive: Send: UIApplicationDidBecomeActiveNotification 

4, Home program
seems to be no running or suspended in the background according to info.plist in Applicationdoes not run in background / UIApplicationExitsOnSuspend control.  
If you can run in the background or experience to hang
the Active -> Inactive -> Background -> Suspended 

the Active -> Inactive 
call applicationWillResignActive: Send: UIApplicationWillResignActiveNotification 
Background -> Suspended 
call applicationDidEnterBackground: Send: UIApplicationDidEnterBackgroundNotification 

If not running in the background or hang will experience
 the Active -> Inactive -> Background -> suspended -> notrunning

Background -> suspended 
call applicationDidEnterBackground: send: on UIApplicationDidEnterBackgroundNotification  
suspended -> Not Running 
Call applicationWillTerminate: Send: UIApplicationWillTerminateNotification

5, after the pending re-run
Suspended -> Background -> Inactive -> the Active

 Background -> Inactive 
 call applicationWillEnterForeground: Send: UIApplicationWillEnterForegroundNotification 
 Inactive -> the Active  
call applicationDidBecomeActive: Send: UIApplicationDidBecomeActiveNotification 

6 , insufficient memory, killing program
 Background -> Suspended -> notrunning
this case does not call any method, it will not send any notice.
 

Guess you like

Origin www.cnblogs.com/hecanlin/p/12024390.html