The life cycle of an iOS app

Source: Internet
Author: User

The life cycle of an iOS app

—————————————————————————— the entry function for the entire application
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions
{

return YES;
}

—————————————————————————— never active to Active state
-(void) Applicationwillresignactive: (uiapplication *) application
{
Sent when the application are about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as a incoming phone call or SMS message) or when the US Er quits the application and it begins the transition to the background state.

The application is switched from active to inactive, and this function will be called (message), which will also occur in some temporary state, such as a call. SMS text message This function will also be called) or when the user exits the application, he starts to switch to background mode
Use the This method to the pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
What should we do??? In this way we have to pause the normal task, turn off the timer, reduce the frequency of the opengless game, pause the game
}

—————————————————————————— have entered the background.

-(void) Applicationdidenterbackground: (uiapplication *) application
{
Use the This method to release the shared resources, save user data, invalidate timers, and store enough application state info Rmation to the restore your application to the it is terminated later.

Use this method to release shared resources, save user data, and void

If your application supports background execution, this method is called instead of Applicationwillterminate:when the User quits.
}

—————————————————————— The callback function that is about to switch to the foreground
-(void) Applicationwillenterforeground: (uiapplication *) application
{
Called as part of the transition from the background to the inactive state; Here's can undo many of the changes made on entering the background.

If you switch from background mode to inactive state, this function is called
Here you can do some of the opposite operations before entering the background, restore the contents of the background saved before
}

———————————————————————— program has been switched to the foreground

-(void) Applicationdidbecomeactive: (uiapplication *) application
{
Restart any tasks this were paused (or not yet started) while the application is inactive. If the application is previously in the background, optionally refresh the user interface.
Restart the suspended business if the application is in the background, then refresh the UI here (User Interface)
}

//

-(void) Applicationwillterminate: (uiapplication *) application
{
Called when the application are about to terminate. Save data if appropriate. See also Applicationdidenterbackground:.

When the application stops the callback function, this only <ios4.0 call alive is greater than ios>4.0
No background mode calls are set
}


The life cycle of an iOS app

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.