Unbalanced calls to begin/end appearance transitions for .

Custom TabBarController Push the next level Controller will report this error: Unbalanced calls to begin/end appearance transitions for <UIVIewController>.

The solution is to add a BOOL type variable to check if it is animating.

if (transiting) {
return;
}
transiting = YES;
[self transitionFromViewController:_currentVC toViewController:newVC duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{

} completion:^(BOOL finished) {

transiting = NO;
}];

This way the bug just mentioned will not appear.

But that doesn’t solve my problem!

So the real answer is

After customizing the TabBarController, you must implement the following

-(void)viewWillAppear:(BOOL)animated
{
[self.selectedViewController beginAppearanceTransition: YES animated: animated];
}

-(void) viewDidAppear:(BOOL)animated
{
[self.selectedViewController endAppearanceTransition];
}

-(void) viewWillDisappear:(BOOL)animated
{
[self.selectedViewController beginAppearanceTransition: NO animated: animated];
}

-(void) viewDidDisappear:(BOOL)animated
{
[self.selectedViewController endAppearanceTransition];
}

Similar Posts: