1 implementation via Appdelegate
App Entry Background Event method
-(void) Applicationdidenterbackground: (uiapplication *) application
App entry to the foreground event method
-(void) Applicationwillenterforeground: (uiapplication *) application
The 2UIViewController class is implemented by listening for notifications of background, foreground events
Example
-(void) Viewwillappear: (BOOL) animated{
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (appwillenterforegroundnotification) name : Uiapplicationwillenterforegroundnotification Object:nil];
}
-(void) appwillenterforegroundnotification{
NSLog (@"trigger event when would enter foreground.");
}
-(void) Viewdiddisappear: (BOOL) animated{
[[Nsnotificationcenter Defaultcenter] removeobserver:self];
}
Note: The Viewdidunload method expires after IOS6 in the Uiviewcontroller class
iOS App response Background,foreground event implementation