title: Unbalanced calls to begin/end appearance transitions for <UIViewController>
body: <p>Based on the <a href="https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html" rel="nofollow">Apple documentation</a> I came up with the following method to switch between controllers in a containment controller. When there is an <code>oldC</code> I am getting <code>Unbalanced calls to begin/end appearance transitions for &lt;...&gt;</code> on the console.</p>
  
  <pre><code>- (void) showController:(UIViewController*)newC withView:(UIView*)contentView animated:(BOOL)animated
  {
      UIViewController *oldC = self.childViewControllers.firstObject;
      if (oldC == newC) {
          return;
      }
  
      [oldC willMoveToParentViewController:nil];
  
      [self addChildViewController:newC];
      newC.view.frame = (CGRect){ 0, 0, contentView.frame.size };
      [contentView addSubview:newC.view];
  
      if (animated &amp;&amp; oldC != nil) {
          oldC.view.alpha = 1.0f;
          newC.view.alpha = 0.0f;
          [self transitionFromViewController:oldC toViewController:newC duration:0.25f options:0 animations:^{
  
              oldC.view.alpha = 0.0f;
              newC.view.alpha = 1.0f;
  
           } completion:^(BOOL finished) {
              [oldC removeFromParentViewController];
              [newC didMoveToParentViewController:self];
           }];
      } else {
          oldC.view.alpha = 0.0f;
          newC.view.alpha = 1.0f;
          [oldC removeFromParentViewController];
          [newC didMoveToParentViewController:self];
      }
  }
  </code></pre>
  
  <p>This is how I call it:</p>
  
  <pre><code>- (IBAction) buttonSignIn:(id)sender
  {
      [self showController:self.signInViewController withView:self.contentView animated:(sender != nil)];
  }
  
  - (IBAction) buttonSignUp:(id)sender
  {
      [self showController:self.signUpViewController withView:self.contentView animated:(sender != nil)];
  }
  </code></pre>
  
  <p>To track this down I am logging the appearance transitions</p>
  
  <pre><code>-(void)beginAppearanceTransition:(BOOL)isAppearing animated:(BOOL)animated
  {
      [super beginAppearanceTransition:isAppearing animated:animated];
      NSLog(@"**begin %@", self);
  }
  
  -(void)endAppearanceTransition
  {
      [super endAppearanceTransition];
      NSLog(@"**end** %@", self);
  }
  </code></pre>
  
  <p>This is what the log looks like:</p>
  
  <pre><code>] **begin &lt;SignInViewController: 0x10c769a20&gt;
  ] **begin &lt;SignUpViewController: 0x10c768770&gt;
  ] Unbalanced calls to begin/end appearance transitions for &lt;SignUpViewController: 0x10c768770&gt;.
  ] **end** &lt;SignUpViewController: 0x10c768770&gt;
  ] **end** &lt;SignInViewController: 0x10c769a20&gt;
  </code></pre>
  
  <p>Now I am a little puzzled. What's the problem here?</p>