在iPad应用程序中隐藏UITabBar [英] Hide UITabBar in iPad Application

查看:158
本文介绍了在iPad应用程序中隐藏UITabBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经被问了很多,有很多答案,但没有答案我可以找到以下答案:

This question has been asked a lot and there are quite a few answers, but none of the answers I can find answer the following:

我有一个UITabBarController

I have a UITabBarController

我想隐藏标签栏,所以我调用:

I want to hide the tab bar, so I call:

self.tabBarController.tabBar.hidden = YES

这会移除栏,但现在有一个空黑框中用于驻留选项卡栏。我试图调整当前正在呈现的ViewController的框架,它总是在标签栏左侧的黑框后面。

This removes the bar, but there is now an empty black box where the tab bar used to reside. I've tried resizing the frame of the ViewController that is currently being presented and it is always behind the black box left from the tab bar.

我也循环遍历所有的子视图并隐藏它们,没有运气。

I also loop through all the subviews and hide them, no luck there.

有没有人有幸运这个?

另外:
hidesBottomBarWhenPushed不工作,因为应用程序不是基于UINavigationViewController,它是基于UITabBarController。

Also: hidesBottomBarWhenPushed doesn't work because the app isn't based on a UINavigationViewController, it is based on a UITabBarController.

这是一个iPad应用程式

This is an iPad app

推荐答案

我也有同样的问题。下面是我如何隐藏标签栏:

I had the same problem. Here is how I have gone about hiding the tab bar:

[self.tabBar removeFromSuperview];
    UIView *contentView;
    if ([[self.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]]) {
        contentView = [self.view.subviews objectAtIndex:1];
    } else {
        contentView = [self.view.subviews objectAtIndex:0];
    }
contentView.frame = self.view.bounds;

这是从tabBarController调用(我有它的子类),但它删除tabBar和调整大小视图去摆脱你现在看到的黑色酒吧。如果你没有一个子类的tabBarController,我相信你可以改变所有的实例 self self.tabBarController

This is called from the tabBarController (I have it subclassed), but it does remove the tabBar and resizes the view to get rid of that black bar you are seeing now. If you don't have a subclassed tabBarController, I'm sure you could just change all instances of self to self.tabBarController and it should work the same.

我希望这有助于

这篇关于在iPad应用程序中隐藏UITabBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆