如何将UIToolbar添加到UIViewController? [英] How can I add a UIToolbar to a UIViewController?

查看:93
本文介绍了如何将UIToolbar添加到UIViewController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIViewController。我想在底部添加一个UIToolbar,但是IB不允许我这样做。我该如何实现?

I have a UIViewController. I want to add a UIToolbar to the bottom, but IB is not letting me. How can I achieve this?

注意:
UIViewController是UINavigationController的一部分。我不确定这是否会影响工具栏的可见性。

Note: The UIViewController is part of a UINavigationController. I'm not sure if this affects the visibility of the toolbar.

推荐答案

从iOS 3.0开始,您可以设置所需的工具栏项目使用以下 UIViewController 的方法:

Starting from iOS 3.0 you can set toolbar items you want using following UIViewController's method:

- (void)setToolbarItems:(NSArray *)toolbarItems animated:(BOOL)animated

的简单设置或覆盖 toolbarItems 属性。

of simply set or override toolbarItems property.

如果将视图控制器放在导航控制器中,工具栏将自动出现。

And toolbar will appear automatically if you put your view controller inside navigation controller.

这篇关于如何将UIToolbar添加到UIViewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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