怎么在某个控制器中判断程序是否在前台或后台

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(appHasGoneInForeground:)
                                      name:UIApplicationWillEnterForegroundNotification
                                           object:nil];  
//别忘了删除监听
[[NSNotificationCenter defaultCenter] removeObserver:self];   


UIApplicationDidEnterBackgroundNotification  //进入后台
UIApplicationWillEnterForegroundNotification //回到程序
posted on 2016-04-20 11:41  X了个code  阅读(314)  评论(0编辑  收藏  举报