最近在项目中遇到一个问题,在自定义了tabbarController以后,在第一个子Vc push后,导航栏会下移20个pt,并且滑动返回失效.同时控制台会报错:
Unbalanced calls to begin/end appearance transitions for ....
但是如果选择了tabbarController的其他子Vc后,在返回第一个VC就没有这个问题了.
这种情况需要在自定义的TabbarController中实现以下代码:
-(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];
}