title: Unbalanced calls to begin/end appearance transitions with segmented control
body: <p>So, I have a segmented control to switch between to view controllers.
  However, often, as soon as I switch, I get this message:</p>
  
  <blockquote>
    <p>Unbalanced calls to begin/end appearance transitions</p>
  </blockquote>
  
  <p>Plus, after I get this, sometimes it happens that every object on the view disappear.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>func segmentValueChanged(sender: AnyObject) {
  
  
      if sender.selectedIndex == 0 {
  
  
  
          let newController = controllers.newController1
          let oldController = childViewControllers.last as UIViewController!
  
  
          self.container.frame.size.height = newController.view.frame.height
  
  
          oldController.willMoveToParentViewController(nil)
          addChildViewController(newController)
  
  
          transitionFromViewController(oldController, toViewController: newController, duration: 0.9, options: .CurveLinear, animations:{ () -&gt; Void in
              // nothing needed here
  
  
              }, completion: { (finished) -&gt; Void in
  
                  oldController.removeFromParentViewController()
                  newController.didMoveToParentViewController(self)
  
  
          })
  
      } else if sender.selectedIndex == 1 {
  
  
          let newController = controllers.newController2
          let oldController = childViewControllers.last as UIViewController!
  
          oldController.willMoveToParentViewController(nil)
          addChildViewController(newController)
  
  
  
  
  
          transitionFromViewController(oldController, toViewController: newController, duration: 0.9, options: .CurveLinear, animations:{ () -&gt; Void in
              // nothing needed here
  
              }, completion: { (finished) -&gt; Void in
  
                  oldController.removeFromParentViewController()
                  newController.didMoveToParentViewController(self)
  
  
          })
      }
  
  }
  </code></pre>
  
  <p>How can I solve this?</p>