Iphone: Is it possible to hide the TabBar? (Pre-iOS 8)

后端 未结 16 1602
广开言路
广开言路 2020-12-05 04:23

I have an application that uses a UITabBarController to switch between modes. When in a certain mode, I\'d like to hide the tab bar until the steps of that mode

相关标签:
16条回答
  • 2020-12-05 05:11

    Do you have the autoResizingMask set on the sub view?

    view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    

    Something like that should do the trick and allow the view sitting atop the stack to re-size.

    0 讨论(0)
  • 2020-12-05 05:13

    See this thread:

    Show/Hide TabBarController in iphone

    In summary, you can see an example of this behavior in this sample code:

    http://developer.apple.com/iphone/library/samplecode/TheElements/index.html

    0 讨论(0)
  • 2020-12-05 05:14

    I use only this single line to achieve this. I use prepareForSegue method before showing the view controller having the tab bar.

    -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
        if([segue.identifier isEqualToString:@"showLogin"]){
            [segue.destinationViewController setHidesBottomBarWhenPushed:YES];
        }
    }
    
    0 讨论(0)
  • 2020-12-05 05:18

    The obvious solution, keeping your original architecture, would have been to present that view modally:

    - (void)tabBarController:(UITabBarController *)tb
     didSelectViewController:(UIViewController *)vc {
        if (tb.selectedIndex == MODALONE) {
            UIViewController* mod = 
                [[UIViewController alloc] initWithNibName: @"ModalView" 
                                                   bundle: nil];
            [tb presentModalViewController:mod animated:NO];
            [mod release];
        }
    }
    

    The view now covers the entire screen (except for the status bar is there is one) including the tab bar, so it looks as if the tab bar has gone away in response to the user pressing that tab bar item.

    0 讨论(0)
  • 2020-12-05 05:18

    put the statement in the init method of the UIViewController

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
            super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
            self.hidesBottomBarWhenPushed = true
            setupDependencyConfigurator()
        }
    
    0 讨论(0)
  • 2020-12-05 05:18

    Just made the following code in Monotouch inside a subclass of UITabBarController:

        public void ShowTabBar()
        {
            UIView.BeginAnimations("Anim");
            UIView.SetAnimationDuration(0.25f);
            this.View.Subviews[0].Frame = new RectangleF(0f, 0f, 320f, 431f);
            this.TabBar.Frame = new RectangleF(0f, 431f, 320f, 49f);
            this.TabBar.Hidden = false;
            UIView.CommitAnimations();
        }
    
        public void HideTabBar()
        {
            UIView.BeginAnimations("Anim");
            UIView.SetAnimationDuration(0.25f);
            this.View.Subviews[0].Frame = new RectangleF(0f, 0f, 320f, 480f);
            this.TabBar.Frame = new RectangleF(0f, 481f, 320f, 510f);
            this.TabBar.Hidden = true;
            UIView.CommitAnimations();          
        }
    
    0 讨论(0)
提交回复
热议问题