IOS app life cycle

Source: Internet
Author: User

Just bought the Dongsheng teacher's iOS book, to record what they feel useful;

As a delegate object for an application, Appdeletage calls different methods at different stages of the application's life cycle.

Let's start by saying the iOS app's v status:

    • Not Running (non-running) application is not running or has been terminated
    • Inactive (foreground inactive) application enters foreground state, but cannot accept event handling
    • Active (foreground active status) application enters foreground to accept events
    • The Background (background state) application enters the background and is still able to execute code. If there is executable code will continue to execute, if not, will go into the suspended state
    • Suspended (hang State) cannot execute code if system memory is not sufficient application will be terminated

iOS applications during these state transitions, the iOS system invokes some methods of appdelegate and sends notifications.

Here are some main ways to say it;

-(BOOL) Application: (uiapplication *) application didfinishlaunchingwithoptions: ( Nsdictionary *) launchoptions

program startup and initialization is called by the

-(void) applicationwillresignactive: (uiapplication *) application

Called when the program moves from the active state to an inactive state


-(void) Applicationdidenterbackground: (uiapplication *) application

This method is called when the program enters the background


-(void) Applicationwillenterforeground: (uiapplication *) application

This method is called when the program enters the foreground but is not yet active


-(void) applicationdidbecomeactive: (uiapplication *) application

Called when the program enters the foreground and is active


-(void) Applicationwillterminate: (uiapplication *) application

Called when the application is terminated


The above 6 methods are automatically generated in APPDEGATE.M;Non-running state---Start scenario program starts with a total of 3 statesNot running->inactive->activeIn the not running->inactive stage the system calls(BOOL) Application: (uiapplication*) Application didfinishlaunchingwithoptions: (nsdictionary*) Launchoptionsin the inactive->active phase, the system calls(void) applicationdidbecomeactive: (uiapplication *) ApplicationClick the Home button---App exit scenario in this case, there are two cases: 1, can be suspended in the background 2, not in the back of the table first said that a total of 4 states experienceactive->inactive->background->suspendedActive->inactive Phase Call(void) Applicationwillresignactive: (uiapplication*) Application
Inactive->background StageThis phase does not invoke the methods listed abovebackground->suspended Phase Call (void) Applicationdidenterbackground: (uiapplication *) application

The second caseActive->inactive->background->suspended->not RunningV Status
The active->inactive system does not invoke the above method, which is different from the first case
Inactive->background StageThis phase does not invoke the methods listed abovebackground->suspended Phase Call(void) Applicationdidenterbackground: (uiapplication *) ApplicationSuspended->not Running Call(void) Applicationwillterminate: (uiapplication*) Application

Suspend re-run scenariosuspended->background->inactive->activeSuspended->background This method is not called here
Background->inactive Call
Applicationwillenterforeground: (uiapplication*) Application
Inactive->active Call
(void) applicationdidbecomeactive: (uiapplication *) application

Memory Purge---Scenario termination the application is running in the background (hangs), and if the system emits a low memory warning, the memory terminator is cleared to meet the memory requirements of other applications. Background->suspended->not running (background->suspended is a pending state after the program has run out of code) in this case the system will not call any method;

IOS app life cycle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.