xcode - 如何将工具栏添加到UITableViewController [英] xcode - How can I add a Toolbar to a UITableViewController
问题描述
我有点问题。我想在我的UITableViewController的按钮中添加一个工具栏,但它不起作用。为什么?
I have a little problem. I wanna add a Toolbar in the button of my UITableViewController, but it doesn't work. Why?
推荐答案
如果您的 UITableViewController
嵌入在<$ c $中c> UINavigationController ,导航控制器附带一个工具栏。你不需要自己添加。
If your UITableViewController
is embedded in UINavigationController
, the navigation controller comes with a toolbar. You wouldn't need to add your own.
导航控制器的工具栏默认是隐藏的。您可以通过以下方式启用它:
The navigation controller's toolbar is hidden by default. You can enable it by:
-
检查导航控制器Interface Builder属性中的显示工具栏选项检查器窗格,或
在代码中设置工具栏可见性:
Setting the toolbar visibility in code:
[self.navigationController setToolbarHidden:NO animated:YES];
启用Storyboard中的工具栏具有以下优势:让你使用Interface Builder将项目拖放到它上面。您还可以通过调用 setToolbarItems:
Enabling the toolbar in Storyboard has the advantage of letting you drag and drop items onto it using Interface Builder. You can also add toolbar items in code, by calling setToolbarItems:
这篇关于xcode - 如何将工具栏添加到UITableViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!