0

我已经将 UINavigationController 设置为我的 mainWindow 的 rootViewController。

我从代码中推送和弹出视图控制器(因此推送和弹出不会由用户交互触发)。

当我在应用程序处于前台时执行此操作时,一切都可以正常工作。

但是当我在应用程序在后台运行时执行此操作时,不会显示正确的 ViewController。

这个问题只能在 iOS 7.x 上重现。

可以在此链接下找到示例项目:https ://www.dropbox.com/sh/pmxnpgtrjxwehs7/_l3NW4xllf

要重现该问题,只需将应用程序置于后台并等待 12 秒,然后将应用程序返回到前台:当您使用 UINavigationBar 的后退按钮导航时,不显示 navigationController 的 rootView(应该如此):背景仍然是绿色,而不是黄色(navigationController 的 rootViewController 的背景是黄色的)。

当应用程序处于前台时,点击带有标签“aaaaa”的按钮会执行相同的导航,但完成后,GUI 处于正确状态。

简而言之:这在应用程序处于前台时有效,但在应用程序处于后台时不起作用:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    NSLog(@"pushViewController!");
    [self pushViewController:[[BViewController alloc] init] animated:YES];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self popToRootViewControllerAnimated:YES];

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self pushViewController:[[BViewController alloc] init] animated:YES];
        });
    });
});

你知道如何解决这个问题吗?

提前致谢!

4

1 回答 1

0

我找到了一个解决方案:我使用此处发布的代码实现了相同的导航动画:stackoverflow.com/questions/9480458/change-animation-transition。使用该代码无法重现该问题!

于 2014-03-24T10:27:32.033 回答