//
//  IWNavigationController.m
//  ItcastWeibo
//
//  Created by mj on 14-1-2.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

#import "IWNavigationController.h"
#import "AppDelegate.h"
//#import "UIBarButtonItem+Addition.h"

@interface IWNavigationController ()<UIGestureRecognizerDelegate>

@end

@implementation IWNavigationController


- (void)viewDidLoad
{
    
    [super viewDidLoad];

    [UIApplication sharedApplication].statusBarHidden = NO;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    viewController.hidesBottomBarWhenPushed = self.viewControllers.count;
    
    // 当不是压入的不是栈底控制器，就隐藏底部的工具条
//    AppDelegate *appDelegate = (AppDelegate *)APPDELEGATE;
//    if (self.viewControllers.count) {
//        viewController.hidesBottomBarWhenPushed = self.viewControllers.count;
    
        //setPanEnabled
        
//        [appDelegate.LeftSlideVC setPanEnabled:NO];
//    }
    
//        else [appDelegate.LeftSlideVC setPanEnabled:YES];
    
    [super pushViewController:viewController animated:animated];
}

//- (void)setViewControllers:(NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated
//{
//    
//    [super setViewControllers:viewControllers animated:animated];
//}
//- (UIViewController *)popViewControllerAnimated:(BOOL)animated
//{
//    if([super popViewControllerAnimated:animated])
//    {
//        AppDelegate *appDelegate = (AppDelegate *)APPDELEGATE;
//        [appDelegate.LeftSlideVC setPanEnabled:(self.viewControllers.count - 1) <= 1?YES:NO];
//        return nil;
//    }else return [super popViewControllerAnimated:animated];
//    
//}

//- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
//{
//    
//     NSLog(@"dad");
//}

//- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
//{
//    [super navi];
//    NSLog(@"dad");
////    
////    viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) icon:@"navigationbar_back" highlightedIcon:@"navigationbar_back_highlighted"];
//    
//    
////    if (viewController != navigationController.viewControllers[0] && viewController.navigationItem.leftBarButtonItem == nil) {
////        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) icon:@"navigationbar_back" highlightedIcon:@"navigationbar_back_highlighted"];
////        
////    }
//
//}


- (void)back
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)more
{
    [self popToRootViewControllerAnimated:YES];
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    return YES;
}
@end
