views:

68

answers:

2

.hidesBottomBarWhenPushed = NO; doesn't work because the view isn't getting pushed. I want the tabBar to be hidden on the first screen and able to show it again a few screens later.

How can I do this?

+1  A: 

This is going to be difficult because tabbars are designed to be the top level of the application's UI. The documentation is very clear on this. As such, they don't play well in a controller hierarchy in which they are not on top.

Really the only way to accomplish what you want is programmatically create the tabbar when you want it to appear. However, I can't say that will produce reliable code. The tabbar will be fighting you all the way.

You really should rethink your UI design. Using the tabbar in a non-standard way will confuse your users. Since the standard is to have tabbars at top level of the UI, users will believe they are at the top level when they see a tabbar. They will get disoriented. You really need to stick to standard usage so that your app agrees with the interface grammar that the users have learned.

See the iPhone Human Interface Guidelines.

TechZen
I don't like this implementation much either. I didn't design the UI but have to code it. I'll check into programatically creating the tabBar.
quantumpotato
I feel your pain. Few things are worse than being trapped implementing a poor design.
TechZen
+1  A: 

Subclass your UITabBarController and add a function like this

- (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;

}   

Whilst your at it, add a function like this to allow the tab bar to rotate

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return allowRotate;
} 
adam
Thanks, I'll give this a shot, and I think I need to make another question for modifying other tabBar behavior. The design calls for a registration screen on startup, but if you've already registered (loading from the phone and sending to server), to push to the next screen, where the tabBars are displayed. Now tapping the tab takes you back to the original registration screen, when the design calls for it to take you to the tabBar view you see after you've registered. *_*
quantumpotato
If this works for you I'd appreciate you flagging the answer as correct!
adam