Visually modifying a UIToolbar from xcode storyboard(从 xcode 故事板可视化修改 UIToolbar)
问题描述
我正在使用 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 UIBarButtonItems 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 IBOutlets 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 xcode 故事板可视化修改 UIToolbar
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
