Many tasks in the iPhone OS 4.0 operating system ~ Method for disabling background execution

Source: Internet
Author: User

 

Recently, an app for iPhone 4.0 OS encountered a home key about exiting the background.Program. I drew some effort and finally found a simple solution to the extreme. Share it here. Because of the multi-task support in the iPhone 4.0 OS, you can press and hold the Home key while running the program. Instead, you can transfer the program to the background. When the program starts again, it continues to run last time, therefore, for some programs, we need to take measures to ensure that the program is cleared from the memory after the home key is pressed. So that at the next entry, the program is restarted, rather than running. The following is a solution to this problem. If you do not need to store any data, you can directly process it as follows.

The solution is to use the-(void) applicationdidenterbackground :( uiapplication *) application method in the uiapplicationdelegate proxy. You only need to execute the exit (0) operation in it.

 

-(Void) applicationdidenterbackground :( uiapplication *) Application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationwillterminate: when the user quits.
*/
Exit (0 );
}

 

Supplement: although the text has been written for some days, I still want to make some supplements here, recently, it was discovered that in addition to the preceding method, you can add an application does not run in background in the XXX-info.plist (XXX is the project name) and check back the checkbox. That's all.

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.