UITabBarController的子类,替换了TabBar并有一个显示问题 [英] Subclass of UITabBarController, replaced the TabBar and have a display issue

查看:159
本文介绍了UITabBarController的子类,替换了TabBar并有一个显示问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用标准UITabBarController构建的iPhone应用程序。此应用程序是使用标准的XCode项目模板创建的。

I have an iPhone app which was built using a standard UITabBarController. This app was created using the standard XCode project template.

现在,我需要更改UITabBar看起来很不同。我决定采取的方法是这样:

Now, I have a requirement to change the UITabBar to look very different. The approach I decided to take was like this:

在我的AppDelegate:

in my AppDelegate:

for (UIView *view in tabBarController.view.subviews) {  
    if([view isKindOfClass:[UITabBar class]]) {
        view.hidden = YES;
        break;
    }
}

这会使标签栏隐藏。接下来,我子类化 UITabBarController ,并添加一个 UIToolbar 和一些自定义组件。在我的子类 UITabBarController 我有我的代码设置,以便当我的一个自定义对象被选中,代码只需调用 [self setSelectedIndex:n] 更新UI。

This works to make the tab bar hidden. Next, I subclassed UITabBarController and I add a UIToolbar with a few custom components. In my subclassed UITabBarController I have my code set up so that when one of my custom objects is selected, the code simply calls [self setSelectedIndex:n] to update the UI.

所以我基本上有一个UITabBarController,但我通过一个新的UI控制它。

So I basically have a UITabBarController but I am controlling it through a new UI.

问题是,我的新组件不像普通的 UITabBar 一样高,UITabBarController似乎没有自动调整我的视图大小。我实际上会期望这种行为,但我不知道如何更改UITabBarController的内容框架。任何想法?

The problem is that my new components aren't quite as tall as the normal UITabBar and the UITabBarController seems to be not resizing my views automatically. I actually would expect this behavior, but I can't figure out how to change the "content frame" of a UITabBarController. Any ideas?

推荐答案

解决了以下代码:

[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 436)];

(我知道这个代码有问题btw,会回来困扰我在iPad或其他设备)。

(I know this code has issues btw and will come back to haunt me on the iPad or other devices).

这篇关于UITabBarController的子类,替换了TabBar并有一个显示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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