1. When the user clicks the home button to apply back to the background again click into the foreground in the Uiviewcontroller controller how to get related events?
2. Requirements
(1) Nstimer The app goes back 10 seconds to 10 minutes will stop (10 minutes or so the general application will be killed) but as long as the background of this nstimer run is sloppy, so I want to stop it when the application into the background
(2) The program supports the background download, when the user stops in the Download management interface, then the user clicks the Home button to make the program run in the background, and so on when the user returns to the program, the download management interface needs to display the latest download progress. (It takes a long time to start the backend service, we only talk about two events in Uiviewcontroller)
3. Implement
This is accomplished using notifications
// Increased monitoring [[Nsnotificationcenter defaultcenter] addobserver:self selector: @selector (apphasgoneinforeground:) Name:uiapplicationwillenterforegroundnotification object: nil]; // Don't forget to delete the listener [[Nsnotificationcenter Defaultcenter] removeobserver:self];
Uiapplicationdidenterbackgroundnotification // Go backstage // go back to the program
Very convenient is not, before I also silly in appdelegate inside judge many conditions to brush page, now want to, that will I really a dick silk, haha
IOS determines the foreground background switch of the application in the View controller Uiviewcontroller