如:应用从后台进入前台
@implementation ListViewController
- (void)viewDidLoad {
[super viewDidLoad];
//监听通知
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(onEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
}
//收到通知执行此方法
- (void)onEnterForeground:(NSNotification *)notification{
//刷新数据
}
- (void)dealloc
{
//移除监听
[NSNotificationCenter.defaultCenter removeObserver:self];
}
@end