我正在使用 XCode 4 和故事板我正在创建的应用程序,但是我无法直观地修改 UIToolbar.
I'm using XCode 4 and storyboarding an application I'm creating, however I cannot visually modify the UIToolbar.
我正在尝试修改 UITableViewController 内部的 UIToolbar - 但是我必须将 UIToolbar 放置在正确的层次结构之外,以便能够在视觉上对其进行修改.我试过把它放在视图控制器区域,但这并没有让它显示出来.
I'm attempting to modify a UIToolbar that is inside of a UITableViewController - however I have to place the UIToolbar out of the correct hierarchy in order to be able to modify it visually. I've tried placing it onto the view controller area but that does not make it show up.
在某一时刻,我能够让它出现在下面,因为它是自己的对象,但是我无法重新创建它.
At one point I was able to make it appear below, as it's own object however I was not able to recreate that.
一旦我能够让它看起来像这样
Once I was able to get it to look like this
你的 UITableViewController
在一个 UINavigationController
里面,它已经有自己的 UIToolbar
——你不需要将一个新的拖入你的视图层次结构中.Interface Builder 可以在 Inspector 面板的Simulated Metrics"下为您模拟工具栏.
Your UITableViewController
is inside a UINavigationController
, which already has its own UIToolbar
—you don't need to drag a new one into your view hierarchy. Interface Builder can simulate the toolbar for you under "Simulated Metrics" in the inspector panel.
一旦模拟工具栏可见,只需将 UIBarButtonItem
拖入其中.如果您需要比按钮或间隔更复杂的东西,请使用带有自定义视图的自定义项.
Once the simulated toolbar is visible, simply drag UIBarButtonItem
s into it. Use a custom item with a custom view if you need anything more complicated than a button or spacer.
如果您需要您的工具栏项目需要是动态的,您可以通过 IBOutlet
维护一个引用,而不必将它们放在您的视图中.然后设置 UITableViewController
的 toolbarItems
属性或在运行时调用 -setToolbarItems:animated:
以显示相应的项目.
If you need your toolbar items need to be dynamic, you can maintain a reference via IBOutlet
s without necessarily having them in your view. Then set your UITableViewController
's toolbarItems
property or call -setToolbarItems:animated:
at runtime to display the appropriate items.
参见 Apple 的 UINavigationController
类参考:显示工具栏.
See Apple's UINavigationController
Class Reference: Displaying a Toolbar.
这篇关于从 xcode 故事板可视化修改 UIToolbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!