The life cycle of apps and controllers

Source: Internet
Author: User

UIApplication Agent Object life cycle function
-(void) Applicationwillresignactive: (uiapplication *) application
Description: When the application is going to be inactive, during which time the application
Not receive messages or events, such as a call

-(void) Applicationdidbecomeactive: (uiapplication *) application
Description: When the application executes in the active state, this is exactly the opposite of the method above

-(void) Applicationdidenterbackground: (uiapplication *) application
Description: Called when the program is pushed to the background. So to set the background to continue running, you can set it in this function
UIApplication Agent Object life cycle function

-(void) Applicationwillenterforeground: (uiapplication *) application
Description: Called when the program is going back to the foreground from the background, which is exactly the opposite of the method above.

-(void) Applicationwillterminate: (uiapplication *) application
Description: When the program is about to exit is called, it is usually used to save the data and some cleanup work before exiting. This needs to set the key value of Uiapplicationexitsonsuspend

(void) Applicationdidreceivememorywarning: (uiapplic ation *) application
Description: iOS devices have limited memory, and if the application is assigned too much memory, the operating system terminates the operation of the application, which is performed before termination, usually where memory cleanup is done to prevent the program from being terminated.
UIApplication Agent Object life cycle function

(void) Applicationdidfinishlaunching: (uiapplication*) a pplication
Description: Executes when the program is loaded.

-(BOOL) Application: (uiapplication*) Application Handleopenurl: (nsurl*) URL
Description: Executes when the URL is opened.


Uiviewcontroller
Uiviewcontroller is the carrier and controller of iOS top-level view, and the interaction between user and program interface is controlled by Uiviewcontroller. Uiviewcontroller manages the life cycle of UIView and the load and release of resources.
UIView UIView and UIWindow have shown the application user interface together.
Uiviewcontroller Life Cycle Events
-(void) Loadview
Load the view resource and initialize the view

-(void) viewdidload
-(void) viewdidunload
Releasing a View resource

-(void) Viewwillappear: (BOOL) animated
will be loaded out of view

-(void) Viewdidappear: (BOOL) animated
View appears

-(void) Viewwilldisappear: (BOOL) animated
The view is about to disappear

(void) Viewdiddisappear: (BOOL) animated
The view has disappeared

The life cycle of apps and controllers

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.