1. the agent method in the Appdelegate can monitor the status of the switch before and after the program
- (void) Applicationdidenterbackground: (UIApplication *) application{NSLog (@"---applicationdidenterbackground----") //Go Backstage}- (void) Applicationdidbecomeactive: (UIApplication *) application{NSLog (@"---applicationdidbecomeactive----") //Access to reception}- (void) Applicationdidenterbackground: (UIApplication *) application{NSLog (@"---applicationdidenterbackground----") //Go Backstage}- (void) Applicationdidbecomeactive: (UIApplication *) application{NSLog (@"---applicationdidbecomeactive----") //Access to reception}
2. Single Viewcontroller listen by registering filter notifications in viewdidload to remove notifications in Dealloc
[[Nsnotificationcenter defaultcenter] addobserver:self selector: @selector (someMethod1:) Object
iOS monitor app resumes from background to foreground