码迷,mamicode.com
首页 > 其他好文 > 详细

tabbar隐藏 重写navigation

时间:2016-10-26 00:38:28      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:int   nsarray   ide   otto   text   ted   nim   port   隐藏   

//
//  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

标签:int   nsarray   ide   otto   text   ted   nim   port   隐藏   

原文地址:http://www.cnblogs.com/xiezefeng/p/5998587.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!