简体   繁体   中英

Tab Bar not hiding Using DDMenuController (Fb like sliding menu)

I am facing this issue from last two days, but could find any solution on it. Can some one help. This is the code snippet am using for TabBar viewControllers.

// Set Up Tab Bar

NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] initWithCapacity:5];

self.tabBarController = [[UITabBarController alloc] init];

[tabBarController

 setDelegate:self];

    UINavigationController *navController = nil;

    NSArray *vcArray = [self papulateViewControllers];

// SetViewController for tab Bar

-(NSArray *) papulateViewControllers{
    BrowseViewController *browseVC = [[BrowseViewController alloc] initWithNibName:@"BrowseViewController" bundle:nil];

    AlbumViewController *albumVC = [[AlbumViewController alloc] initWithNibName:@"AlbumViewController" bundle:nil];


    SubmitStep1VC *submitVC = [[SubmitStep1VC  alloc] initWithNibName:@"SubmitStep1VC" bundle:nil];
    // SubmitStep1VC *submitVC = [[SubmitStep1VC  alloc] initWithNibName:@"SubmitStep1_iPhone5.xib" bundle:[NSBundle mainBundle]];

    WallViewController *wallVC = [[WallViewController  alloc] initWithNibName:@"WallViewController" bundle:nil];

    OptionVC *optionVC = [[OptionVC alloc] initWithNibName:@"OptionVC" bundle:nil];


    sliderVCRef = [[SliderVC alloc] initWithNibName:@"SliderVC" bundle:nil];

    //Navigation Controllers
    UINavigationController *browseNavController = [[UINavigationController alloc] initWithRootViewController: browseVC];
    [browseNavController setNavigationBarHidden:YES];

    UINavigationController *albumNavController = [[UINavigationController alloc] initWithRootViewController: albumVC];
    [albumNavController setNavigationBarHidden:YES];

    UINavigationController *submitNavController = [[UINavigationController alloc] initWithRootViewController: submitVC];
    [submitNavController setNavigationBarHidden:YES];

    UINavigationController *wallNavController = [[UINavigationController alloc] initWithRootViewController: wallVC];
    [wallNavController setNavigationBarHidden:YES];

    UINavigationController *optionNavController = [[UINavigationController alloc] initWithRootViewController: optionVC];
    [optionNavController setNavigationBarHidden:YES];

    DDMenuController *browseMenuController = [[DDMenuController alloc] initWithRootViewController:browseNavController];

    self.menuController = browseMenuController;
    self.menuController.leftViewController = sliderVCRef;

    DDMenuController *albumMenuController = [[DDMenuController alloc] initWithRootViewController:albumNavController];
    albumMenuController.leftViewController = sliderVCRef;

    DDMenuController *submitMenuController = [[DDMenuController alloc] initWithRootViewController:submitNavController];
    submitMenuController.leftViewController = sliderVCRef;

    DDMenuController *wallMenuController = [[DDMenuController alloc] initWithRootViewController:wallNavController];
    wallMenuController.leftViewController = sliderVCRef;

    DDMenuController *optionMenuController = [[DDMenuController alloc] initWithRootViewController:optionNavController];
    optionMenuController.leftViewController = sliderVCRef;

/// Works fine if i uncomment this line and comment next line of code (Passing Viewcontrollers is fine )

//   return [NSArray arrayWithObjects:self.menuController, albumVC, submitVC, wallVC, optionVC, nil];


////*******  issue in case i use this line   (Passing menuController creates issue of Tabbar )

    return [NSArray arrayWithObjects:self.menuController, albumMenuController, submitMenuController, wallMenuController, optionMenuController, nil];

////////////

}

When i try to push to push to any viewcontroler from any above TabBarController Tab bar is not hiding . example

grandPrizeVC.hidesBottomBarWhenPushed = YES;

Its keep showing me tab bar. If i try appDelegate.tabbarcontroller.tabbar.hidden = YES; It shows on a black bottom bar on new VC.

Your app doing just what you have implemented. You are adding your sliding menu view controller as subview controller to tabbar controller, of course, it won't hide. Some suggestions to hide tabbar: 1. Add tabbar controller as modal to your DDMenuController 2. write some methods to hide/show tabbar (searching hide tabbar will give you the answers, or you could just traverse subviews of tabbar controller's view find tabbar and hide it). Good luck!

Following worked for me :

Show TabBar :

+ (void) showTabBar{

    MyAppDelegate* appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication]delegate];
    UITabBar *tabBar = appDelegate.tabBarController.tabBar;
    UIView *parent = tabBar.superview; // UILayoutContainerView
    UIView *content = [parent.subviews objectAtIndex:0];  // UITransitionView
    UIView *window = parent.superview;
    CGRect tabFrame = tabBar.frame;
    tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabBar.frame);
    tabBar.frame = tabFrame;

    CGRect contentFrame = content.frame;
    contentFrame.size.height -= tabFrame.size.height;
}

Hide TabBar:

+(void) hideTabBar{
   MyAppDelegate* appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication]delegate];
    UITabBar *tabBar = appDelegate.tabBarController.tabBar;
    UIView *parent = tabBar.superview; // UILayoutContainerView
    UIView *content = [parent.subviews objectAtIndex:0];  // UITransitionView
    UIView *window = parent.superview;

    [UIView animateWithDuration:0.01
                     animations:^{
                         CGRect tabFrame = tabBar.frame;
                         tabFrame.origin.y = CGRectGetMaxY(window.bounds);
                         tabFrame.origin.y +=20;
                         tabBar.frame = tabFrame;
                         content.frame = window.bounds;
                     }];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM