views:

203

answers:

1

I've got an application that uses a Tab Bar Controller along with a Navigation Controller.But for some pages I want to hide both bars(Tab & navigation) after that those will be visible again...I am able to hide navigation bar & also done with making. it appear after some pages. I am able to hide tab bar with - (BOOL)hidesBottomBarWhenPushed{ return TRUE; }

But problem is how do I make it Visible again after some pages?

+1  A: 

Please prove yourself a good stackoverflow user and accept/upvote my answer :)

[[self navigationController] setNavigationBarHidden:UIDeviceOrientationIsLandscape(toInterfaceOrientation) animated:YES];

then in a subclassed UITabBarController

- (void) hideTabBar:(BOOL)hide animated:(BOOL)animated {

    if (tabBarHidden == hide) { return; }

    if (animated) {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:1.5];
    }

    for(UIView *view in self.view.subviews) {

        if([view isKindOfClass:[UITabBar class]]) {

            if (!hide) {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y-49, view.frame.size.width, view.frame.size.height)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+49, view.frame.size.width, view.frame.size.height)];
            }
        } else {
            if (!hide) {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-49)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height+49)];
            }

        }
    }

    if (animated) { [UIView commitAnimations]; }

    tabBarHidden = hide;

}
adam
Thanks for your reply.....But its not working :(
priya
make sure you subclass a UITabBarController and include this method within it
adam
Yes,I tried above code in subclassed UITabBarController....but not working..
priya
Can you be more specific? This code was copied straight out of where I am using it in my code, where it works. Obviously you need to declare tabBarHidden outside of the scope of this method.
adam