tabbar隐藏 重写navigation
Posted 谢小锋
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tabbar隐藏 重写navigation相关的知识,希望对你有一定的参考价值。
//
// ZFNavigationController.m
// Cartext
//
// Created by 谢泽锋 on 16/3/20.
// Copyright ? 2016年 xiezefeng. All rights reserved.
//
#import "ZFNavigationController.h"
@interface ZFNavigationController ()
@end
@implementation ZFNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
//-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
// if (self.viewControllers.count > 0) {
// viewController.hidesBottomBarWhenPushed = YES;
// }
// [super pushViewController:viewController animated:YES];
//}
-(UIViewController *)popViewControllerAnimated:(BOOL)animated
{
if (self.viewControllers.count > 0) {
self.tabBarController.tabBar.hidden=YES;
}else{
self.tabBarController.tabBar.hidden=NO;
}
return [super popViewControllerAnimated:animated];
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
// 第一个 控制器 不需要隐藏tabbar
if (self.viewControllers.count > 0) {
viewController.hidesBottomBarWhenPushed = YES;
self.tabBarController.tabBar.hidden=YES;
}else{
self.tabBarController.tabBar.hidden=NO;
}
[super pushViewController:viewController animated:animated];
}
- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated
{
// 第一个 控制器 不需要隐藏tabbar
if (self.viewControllers.count > 2) {
[self.tabBarController.tabBar setHidden:YES];
} else {
[self.tabBarController.tabBar setHidden:NO];
}
return [super popToViewController:viewController animated:animated];
}
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
{
[self.tabBarController.tabBar setHidden:NO];
return [super popToRootViewControllerAnimated:animated];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (self.viewControllers.count > 1) {
[self.tabBarController.tabBar setHidden:YES];
} else {
[self.tabBarController.tabBar setHidden:NO];
}
}
@end
以上是关于tabbar隐藏 重写navigation的主要内容,如果未能解决你的问题,请参考以下文章