1
votes

I have a process that consists of three views (and relevant ViewControllers). When the user arrives at the third, they may choose to repeat the step #2. If this happens, i create a new viewcontroller of step 2 with some values and push that using the navigationController. However, i want to amend the viewControllers array so that if user goes back they dont end up in step 3, but rather in step 1.

So i push my viewController and then remove the extraneous ones #3 and #2 from the stack like so:

    NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: step2AgainVc.navigationController.viewControllers];
[navigationArray removeObjectAtIndex: navigationArray.count - 3];
[navigationArray removeObjectAtIndex: navigationArray.count - 2];
[step2AgainVc.navigationController setViewControllers:navigationArray animated:NO];

However, this results in the following Console waring:

Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

Apart from this, everything works as expected. Now this is the first app that i plan to submit to App Store (worked on Enterprise Distributioned ones only before), so i would like to refactor the method to not get the warning. Any suggestions?

1

1 Answers

0
votes

You need to modify the array either before starting the push of the new controller or after it has completed animating in. The problem reported by the warning is that you have changed the navigation controller state while it's in the middle of the animation so it can't guarantee that everything will work properly.