将UITabBar移到UITabBarController的顶部? [英] Move UITabBar to the top of a UITabBarController?

查看:225
本文介绍了将UITabBar移到UITabBarController的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚完成了一个应用程序的设计,该应用程序使用在三个UIViewControllers之间切换的顶部栏.我的第一个念头是使用UITabBarController,因为它非常相似.

I just finished designing a application that uses a top bar that toggles between three UIViewControllers. My first thought was to use a UITabBarController, since it works very simular.

但是,tabBar在底部,而在我的PSD中,它在顶部.无论如何,我可以更改它吗?我在库中看到可以在UITabBar中拖动,但是我不知道如何从那里更改页面.

However, the tabBar is at the bottom and in my PSD, it's at the top. Is there anyway I can change it? I see in the library I can drag in a UITabBar, but I don't know how to get it to change pages from there.

请帮助! 库尔顿

推荐答案

我认为可以做到,但您应该注意

I think it can be done, but you should be aware of this:

重要提示:在iPhone OS 3.0和更高版本中,当它与选项卡栏控制器对象相关联时,您不应尝试使用此类的方法和属性来修改选项卡栏.通过这种方式修改选项卡栏会导致相反,对选项卡栏或其项的任何修改都应通过选项卡栏控制器界面进行.您仍然可以直接修改与选项卡栏控制器无关的选项卡栏对象."

"Important: In iPhone OS 3.0 and later, you should not attempt to use the methods and properties of this class to modify the tab bar when it is associated with a tab bar controller object. Modifying the tab bar in this way results in the throwing of an exception. Instead, any modifications to the tab bar or its items should occur through the tab bar controller interface. You may still directly modify a tab bar object that is not associated with a tab bar controller."

因此,在您的UI(我想您在Interface Builder中定义了它)中,实例化一个UITabBar对象(通过在IB库中选择它并将其拖到IB中的视图中).选择默认位置,并定义此选项卡栏自动调整大小的方式(使用信息窗口的大小窗格).然后,将插座添加到UITabBar类型的视图控制器中,最后,将选项卡栏对象连接到选项卡栏插座.

So, in your UI (I suppose you defined it in Interface Builder), instantiate a UITabBar object (by choosing it in the IB library and dragging it to your view in IB). Choose the default position and also define the way that this tab bar autoresizes (using the size pane of the info window). Then, add an outlet to your view controller of type UITabBar, and, finally, connect the tab bar object to the tab bar outlet.

完成此操作后,可以在视图控制器的viewDidLoad方法中自定义所需的选项卡栏的任何属性.

Once you have done this, in your view controller's viewDidLoad method you can customize any property of the tab bar that you want to.

这篇关于将UITabBar移到UITabBarController的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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