iOS开发之监听应用进入前台后台

时间:2022-03-11 07:13:19

//后台进前台通知 UIApplicationDidBecomeActiveNotification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];

//进入后台UIApplicationDidEnterBackgroundNotification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];

我们