ios 界面构建器中的组合框对象在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20054513/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where is the combobox object in interface builder?
提问by jedimariachi
I just updated to Xcode 5.0.2 and in interface builder on the lower right corner where I can drag and drop objects I don't see combobox any more. I tried using the search field below and typed combobox, NSCombobox, but nothing.
我刚刚更新到 Xcode 5.0.2 并在右下角的界面构建器中,我可以拖放我看不到组合框的对象。我尝试使用下面的搜索字段并输入组合框、NSCombobox,但什么也没有。
回答by Wilmar
Using a UIPickerViewwill probably get you far
使用UIPickerView可能会让你走得更远
回答by thpitsch
It's easy to make a ComboBox lookalike. It consists of only three parts in InterfaceBuilder xib:
使 ComboBox 看起来相似很容易。它在 InterfaceBuilder xib 中仅由三部分组成:
- A Label for holding the selected choice. I've made it with a white background to look like an input field.
- A graphic Button with an arrow
- A ListView
- 用于保存所选选项的标签。我用白色背景使它看起来像一个输入字段。
- 带箭头的图形按钮
- 一个列表视图
The ListView is normally invisible (setHidden:TRUE) and is placed over other items in this xib. A tap on the Button makes the ListView visible (setHidden:FALSE). At selection, didSelectRowAtIndexPath writes the selected string to the label and set ListView hidden.
ListView 通常是不可见的 (setHidden:TRUE) 并放置在此 xib 中的其他项目上。点击 Button 使 ListView 可见(setHidden:FALSE)。在选择时, didSelectRowAtIndexPath 将选定的字符串写入标签并设置 ListView 隐藏。
回答by Mark Szymczyk
Combo boxes are available only for Mac projects, not iOS projects, so you're getting the expected behavior. If you create a Cocoa application project and type combo in the object library's search field, the combo box and combo box cell objects should appear in the object library.
组合框仅适用于 Mac 项目,不适用于 iOS 项目,因此您将获得预期的行为。如果您创建 Cocoa 应用程序项目并在对象库的搜索字段中键入组合,组合框和组合框单元格对象应该出现在对象库中。
I'm surprised you were able to access a combo box in earlier versions of Xcode. I don't remember combo boxes ever being available in iOS projects.
我很惊讶您能够在早期版本的 Xcode 中访问组合框。我不记得组合框曾经在 iOS 项目中可用。
回答by Darkseal
I also needed a HTML select-like control (single-selection dropdown list) without breaking the XCode legacy GUI interface across past and future iOS releases.
我还需要一个类似 HTML 选择的控件(单选下拉列表),而不会破坏过去和未来 iOS 版本的 XCode 遗留 GUI 界面。
I ended up coding DownPicker, a lightweight control which does just that combining UITextField
and UIPickerView
. It can be used either as custom control (UIDownPicker
) or also as control wrapper, upgrading any existing UITextField
.
我最终编写了 DownPicker,这是一个轻量级控件,它可以将UITextField
和UIPickerView
. 它既可以用作自定义控件 ( UIDownPicker
),也可以用作控件包装器,升级任何现有的UITextField
.
Here's how it looks like:
这是它的样子:
For more info and download you can check this brief tutorialor the GitHub project page(both made by me - the project is open-source).
有关更多信息和下载,您可以查看此简短教程或GitHub 项目页面(均由我制作 - 该项目是开源的)。