Full screen in one tab of UITabBarController

别来无恙 提交于 2019-12-11 10:19:48

问题


Currently, five UIViewControllers are switched via a UITabBarController. How can I hide the TabBar and provide a full-screen for one of the UIViewControllers?

For example:

  • The middle tab is clicked
  • The UITabBarController TabBar is hidden
  • The UIViewController takes full screen (hides status bar also)
  • When one button in the middle is clicked, switch to the first tab (status bar resumes, UITabBarController TabBar resumes)

回答1:


You can put the view controller in a navigation controller and set the view controller's hidesBottomBarWhenPushed property to YES. Hiding the status bar can be done using statusBarHidden property of the shared application object.




回答2:


First, right-click the tab bar in Interface Builder and drag "delegate" to "File's Owner".

Then, add the following method to the tab bar controller:

– (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    [UIView animateWithDuration:0.5 animations:^(void) {
        tabBar.transform = CGAffineTransformMakeTranslation(0, 480);
    }];
}

and when a button is clicked, add the tabbar as an outlet to the tab bar controller, and then do the following when the button is pressed:

[UIView animateWithDuration:0.5 animations:^(void) {
        tabBarController.tabBar.transform = CGAffineTransformMakeTranslation(0, 431);
}];

Done!




回答3:


To hide the tab bar, you can use:

    tabBarController.tabBar.hidden = YES;

you can call this from the viewWillAppear method of the controller associated to the middle tab bar view, or in your tab bar controller delegate's –tabBarController:shouldSelectViewController:

You will have to do the opposite in viewWillAppear of all other view controllers, or when clicking the "resume" button;

In order to hide the status bar:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

at the same places as above.




回答4:


I solved the issue by doing the following.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

segue.destinationViewController.hidesBottomBarWhenPushed = YES

}


来源:https://stackoverflow.com/questions/6281876/full-screen-in-one-tab-of-uitabbarcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!