26

After some research on the web without success, I come here to ask you the question about my warning.

Actually, I have a view V1 with a navigation controller and I want to push a modal view V2 when V1 has finished loading. So I use the performSegueWithIdentifier method (I'm using storyboard). Here is my code:

[self performSegueWithIdentifier:@"showConnexionViewSegue" sender:self];

And when I compile, I got this warning:

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

Can anyone help me?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Vinestro
  • 1,072
  • 1
  • 10
  • 32

4 Answers4

58

It sounds like you may be performing the segue in -viewWillAppear: thus generating two -viewWillAppear: messages without 2 corresponding -viewDidAppear messages.

Try performing the segue in -viewDidAppear.

Mark Adams
  • 30,776
  • 11
  • 77
  • 77
  • 5
    I had encountered this by performing the segue in `-viewDidLoad`, and I was working around it by calling `performSegue` inside a `performSelector:withObject:afterDelay` with a delay of 0, but that was messy. This fix allows me to call `performSegue` directly in `-viewDidAppear:`. Thanks! – Zev Eisenberg Feb 04 '12 at 23:30
  • Had a pop call in viewdidload. Moved the call into viewdidappear, and it fixed it for me. – ninjaneer Feb 02 '13 at 00:50
  • `-viewDidAppear:` is a method on `UIViewController` that can be overridden in your `UIViewController` subclasses. The `-viewDidAppear:` message is sent to your view controller once the view has appeared on screen. – Mark Adams Mar 28 '13 at 01:22
  • You are the best. Saved my day. Thax a lot for sharing this. – Janak Nirmal Jun 05 '13 at 11:00
5

I had this problem, but what I had done is on a UIViewController I had linked a Segue from a UIButton and also coded it into a nextBtnPressed: function, so I was actually pushing two new UIViewControllers on the one button press. Limiting it to just the one segue fixed it. But it took some investigating to see that I had done this double up.

DonnaLea
  • 8,643
  • 4
  • 32
  • 32
5

'Unbalanced calls to begin/end appearance transitions for '

Says an animation is started before the last related animation isnt done. So, are you popping any view controller before pushing the new one ? Or may be popping to root ? if yes try doing so without animation i.e. [self.navigationController popToRootViewControllerAnimated:NO];

And see if this resolves the issue, In my case this did the trick.

infiniteLoop
  • 2,135
  • 1
  • 25
  • 29
1

The reasons for this are manifold and are very specific to the context and the programming. For example, what I was doing was

  1. initialising a sound file, playing it (asynchronously) for 1.4 seconds,
  2. making an image move across the screen using animation timed to last 1.4 seconds and,
  3. with a timer set to 1.4 seconds after step 2, pushing a viewcontroller.

What i discovered is that if I DO NOT have the instructions for these 3 steps one after the other (if I mix them up), then I get the error "Unbalanced calls...". Also, if I time the push of the viewcontroller to less than 1.4 seconds, I get the message as well.

So, check that the sequence and timing of your program instructions are correct.

Anjaan
  • 660
  • 6
  • 10