iOS app life cycle

Source: Internet
Author: User

1, application state 1.1, not running-is not running

Program does not start

1.2, inactive-not activated

The program runs in the foreground, but no events are received, and the program stays in this state without event handling

1.3. active-activation

The program runs in the foreground and receives the event, which is also a normal mode of the foreground

1.4, background-backstage

The program in the background and can execute code, most of the program into this state will stay in this state for a while, the time will go into the suspended state, some programs after a special request can be long-term background state

1.5, suspended-Hang

The program cannot execute code in the background. The system automatically turns the program into this state and does not give notice. When hanging, the program is still in memory, when the system memory is low, the system will remove the suspended program, to provide more memory for the foreground program

2. Life cycle Method 2.1, –application:willfinishlaunchingwithoptions:

Tells the agent that the process has started but has not yet entered a state save

2.2, –application:didfinishlaunchingwithoptions:

Tells the agent to start the basic Completion program ready to start running

2.3, –applicationdidbecomeactive:

When an application enters the active state execution

2.4, –applicationwillresignactive:

When an application is going into an inactive state, during which time the application does not receive messages or events, such as calling

2.5, –applicationdidenterbackground:

Called when the program is pushed to the background

You can start a background task in block again

[Application beginbackgroundtaskwithexpirationhandler:^{

NSLog (@ "Begin Background Task with Expiration Handler");

}];

2.6, –applicationwillenterforeground:

Called when the program is going back to the foreground from the background

2.7, –applicationwillterminate:

is called when the program is going to exit

2.8, –applicationdidfinishlaunching:

This method was used in earlier versions for IOS to initialize the app and prepare it to run. In IOS 3.0 and later, you should use the Application:didFinishLaunchingWithOptions:instead. In IOS 6.0 and later, your may also use the Application:willFinishLaunchingWithOptions:method to initialize your app.

3, the related Operation 3.1, the program starts

1, –application:willfinishlaunchingwithoptions:

2 , –application:didfinishlaunchingwithoptions:

3, –applicationdidbecomeactive:

3.2, into the background

1, –applicationwillresignactive:

2, –applicationdidenterbackground:

3.3. Enter the front desk

1 , –applicationwillenterforeground:

2, –applicationdidbecomeactive:

3.3. Close the program

1, –applicationdidenterbackground:

2, –applicationwillterminate:

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.