- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (!prevViewControllers)
prevViewControllers = [navigationController viewControllers];
// We detect is the view as been push or popped
BOOL pushed;
if ([prevViewControllers count] <= [[navigationController viewControllers] count])
pushed = YES;
else
pushed = NO;
// Logic to know when to show or hide the tab bar
BOOL isPreviousHidden, isNextHidden;
isPreviousHidden = [[prevViewControllers lastObject] hidesBottomBarWhenPushed];
isNextHidden = [viewController hidesBottomBarWhenPushed];
prevViewControllers = [navigationController viewControllers];
UIViewController *vc = [prevViewControllers lastObject];
NSLog(@"%@", vc);
if (!isPreviousHidden && !isNextHidden)
return;
else if (!isPreviousHidden && isNextHidden)
{
[self hideTabBar:(pushed ? AKShowHideFromRight : AKShowHideFromLeft) animated:animated];
}
else if (isPreviousHidden && !isNextHidden)
{
NSLog(@"2");
[self showTabBar:(pushed ? AKShowHideFromRight : AKShowHideFromLeft) animated:animated];
[vc.view setNeedsLayout]; // <======= ПО ВАШЕМУ СОВЕТУ
}
else if (isPreviousHidden && isNextHidden)
{
return;
}
}