Based on the Apple documentation I came up with the following method to switch between controllers in a containment controller.
But when there is an oldC I am getting "Unbalanced calls to begin/end appearance transitions for <...>" on the console. - (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 && 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]; } } This is how I call it: - (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)]; } To track this down I am logging the appearance transitions -(void)beginAppearanceTransition:(BOOL)isAppearing animated:(BOOL)animated { [super beginAppearanceTransition:isAppearing animated:animated]; NSLog(@"**begin %@", self); } -(void)endAppearanceTransition { [super endAppearanceTransition]; NSLog(@"**end** %@", self); } This is what the log looks like: ] **begin <SignInViewController: 0x10c769a20> ] **begin <SignUpViewController: 0x10c768770> ] Unbalanced calls to begin/end appearance transitions for <SignUpViewController: 0x10c768770>. ] **end** <SignUpViewController: 0x10c768770> ] **end** <SignInViewController: 0x10c769a20> Now I am a little puzzled. What's the problem here? cheers, Torsten _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com