0

I have set up a UINavigationController as rootViewController of my mainWindow.

I push and pop viewcontrollers from code (so pushes and pops are not triggered by user interaction).

When I do it when the applicaiton is in the foreground, everyhting works as it should.

But when I do it when the application is running in the background, not the correct ViewController is shown.

This issue is reproducible only on iOS 7.x .

A sample project can be found under this link : https://www.dropbox.com/sh/pmxnpgtrjxwehs7/_l3NW4xllf

To reproduce the issue, just put the app into the background and wait 12 second and return the app to the foreground : when you navigate using UINavigationBar's back button, not the navigationController's rootView is shown (as it should) : the background is still green, and not yellow (the navigationController's rootViewController's background is yellow).

When the app is in the foreground, tapping on the button with the label "aaaaa" does the same navigation but when it's done, the GUI is in correct state.

So in brief : This works when the app is in the foreground but does not work when the app is in the background :

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];
        });
    });
});

Do you know how could this issue be solved?

Thanks in advance!

stoflow
  • 163
  • 1
  • 10
  • Post some code please. – Marco Pace Mar 24 '14 at 09:48
  • Its not a good idea to perform push / pop operation in background. Why don't you do it when the application enter foreground? – Marco Pace Mar 24 '14 at 09:53
  • I've just added a link to a sample project that can be downloaded as a zip from Dropbox and I've highlighted the most important part of the code that can be used to reproduce the bug. – stoflow Mar 24 '14 at 09:55
  • I've already tried to implement queuing up navigations when the app is in the background and executing them when the app returns to the foreground but for some reason the problem is still reproducible... I will update the sample code with that fix... – stoflow Mar 24 '14 at 09:57
  • Just a simple question, why are you pushing / popping / pushing the same controller after 3 seconds? Are you sure there doesn't exists another way to do the same thing? – Marco Pace Mar 24 '14 at 10:18
  • Never mind I've found a solution : I achieve the same navigation animation using the code posted here : http://stackoverflow.com/questions/9480458/change-animation-transition . The problem is not reproducible using that code! – stoflow Mar 24 '14 at 10:26

1 Answers1

0

I've found a solution : I achieve the same navigation animation using the code posted here : stackoverflow.com/questions/9480458/change-animation-transition . The problem is not reproducible using that code!

Community
  • 1
  • 1
stoflow
  • 163
  • 1
  • 10