Wilson Yuan
Wilson Yuan

Reputation: 35

Unbalanced calls to begin/end appearance transitions for <UINavigationController: *****>

Here is my code:

UINavigationController *navigaitonController = [[UINavigationController alloc] initWithRootViewController:tips];
navigaitonController.modalPresentationStyle = UIModalPresentationCustom;
navigaitonController.transitioningDelegate = tips.transiction;
navigaitonController.modalPresentationCapturesStatusBarAppearance = YES;
[controller presentViewController:navigaitonController animated:YES completion:nil];

when tips controller be presented or dismissed, the console log:

Unbalanced calls to begin/end appearance transitions for <UINavigationController: *****>

what's the problem? Please help me.

Upvotes: 0

Views: 4450

Answers (2)

Mr.Javed Multani
Mr.Javed Multani

Reputation: 13236

This occurs when you try and display a new viewcontroller before the current view controller is finished displaying. You can reproduce it by navigating in viewWillAppear.

Basically you are trying to push two view controllers onto the stack at almost the same time. Suggest you maintain a queue in the tableview controller which maintains a list of the detail views which need displaying. Push one at a time on to the stack and check on exit from the current detail view whether there are any queued detail views which need displaying.

This kind of navigation is going to be confusing for the user. It may be better to consider making your detail view support multiple items.

You're absolutely right. viewWillAppear and viewDidAppear are going to fire every time the modal opens and closes. It seems like the following are the only solutions:

  • Disable the animation on the modal
  • Wait until the navigation controller has finished its animation.

  • Move the code into a new method and call the method after a delay

Upvotes: 3

jegadeesh
jegadeesh

Reputation: 945

Set animated to NO while presenting the view controller.

This message is triggered because you are trying to present a view controller before the previous view controller's animation is still going on

Upvotes: -1

Related Questions