IOS BUG: Unbalanced cballs to begin/end appearance transitions for <XXXViewController: 0x7fcea3730650>., unbalanced
The following error is reported when the custom TabBarController pushes a lower-level Controller: Unbalanced callto begin/end appearance transitions for <XXXViewController: 0x7fcea3730650>.
Some answers on the Internet are caused by animation. The solution is to add a Boolean variable to check whether the animation is ongoing.
If (transiting ){
Return;
}
Transiting = YES;
[Self transitionFromViewController: _ currentVC toViewController: newVC duration: 0.5 options: UIViewAnimationOptionTransitionCrossDissolve animations: ^ {
} Completion: ^ (BOOL finished ){
Transiting = NO;
}];
In this way, the bug just mentioned will not appear.
However, this does not solve my problem!
So the real answer is:
After customizing 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];
}