-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES]; //接收后台到前台的通知,更新开关状态 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imcomingBack) name:UIApplicationDidBecomeActiveNotification object:nil]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:YES]; [[NSNotificationCenter defaultCenter] removeObserver:self];//移除通知 } - (void)imcomingBack{//从后台回来后刷新开关状态 if (IAIOS7) { [UserModel shareInstance].isOpenNoti = (UIRemoteNotificationTypeNone != [[UIApplication sharedApplication] enabledRemoteNotificationTypes]); }else{ [UserModel shareInstance].isOpenNoti = (UIUserNotificationTypeNone != [[UIApplication sharedApplication] currentUserNotificationSettings].types); } [self.userView.tableView reloadData]; }