系统通知
- (void)viewDidLoad {
[superview DidLoad];
//从后台进入前台的通知
//UIApplicationWillEnterForegroundNotification应用从后台将要进入前台(活动状态)的时候
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Method1) name:UIApplicationWillEnterForegroundNotification object:nil];
//进入后台的通知
//UIApplicationDidEnterBackgroundNotification应用将要进入后台(失去活动状态)的时候
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Method2) name:UIApplicationDidEnterBackgroundNotification object:nil];
//UIApplicationWillResignActiveNotification将要取消活跃状态
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Method3) name:UIApplicationWillResignActiveNotification object:nil];
//UIApplicationDidBecomeActiveNotification应用进入活跃状态
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Method4) name:UIApplicationDidBecomeActiveNotification object:nil];
//UIApplicationWillTerminateNotification被动终止(比如来电)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Method5) name:UIApplicationWillTerminateNotification object:nil];
}
- (void)Method1 {
NSLog(@"应用进入前台(活动状态)的时候");
}
- (void)Method2 {
NSLog(@"应用将要进入后台(失去活动状态)的时候");
}
- (void)Method3 {
NSLog(@"将要取消活跃状态");
}
- (void)Method4 {
NSLog(@"应用进入活跃状态");
}
- (void)Method5 {
NSLog(@"UIApplicationWillTerminateNotification");
}