应用在iOS 7中使用applicationDidEnterBackground进入后台时无法更新视图:

gup*_*ron 4 background objective-c foreground ios ios7

当我的应用程序进入后台时,我正在更改视图以准备它回到前台.在iOS 6中,我正在做的工作正常.但是在iOS 7中,它无法正常工作.

我试图隐藏并显示一些像这样的UILabel:

//AppDelegate.m
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [self.timerVc hideTimerLabels];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [self.timerVc showTimerLabels];
}


//TimerVC.m
- (void)hideTimerLabels {
    for (UILabel *label in self.timerLabels) {
        label.hidden = YES;
    }
}

- (void)showTimerLabels {
    for (UILabel *label in self.timerLabels) {
        label.hidden = NO;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我设置断点时,所有这些代码都会触发,但似乎没有做任何事情.我也测试了这些hideTimerLabelsshowTimerLabels方法,它们在iOS 7中运行良好.

gup*_*ron 5

看起来这只发生在模拟器中.在具有iOS 7的实际设备上,它按预期工作.另一个提醒,更频繁地在设备上进行测试.