xcode iPhone 应用程序的下拉列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6198186/
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
Drop down list for iPhone application
提问by Gayan
How can I add drop-down list to my iPhone application via Interface builder in Xcode 4. I can't see any object like drop-down list controller or something like that?
如何通过 Xcode 4 中的界面构建器将下拉列表添加到我的 iPhone 应用程序。我看不到任何对象,如下拉列表控制器或类似的东西?
回答by Tom H
I belive the control you might want is the UIPicker (Here's an image, its at the bottom). This is the control that pops up when you select a dropdown list in safari on iOS. You can select it in the object picker in the interface editing area. There is no dropdown list controller as such, as far as I know.
我相信您可能想要的控件是 UIPicker(这是一个图像,位于底部)。这是在 iOS 上的 safari 中选择下拉列表时弹出的控件。您可以在界面编辑区的对象选择器中选择它。据我所知,没有这样的下拉列表控制器。
回答by petert
You can use UIPickerView
, but it sounds like your more likely after UIActionSheet
which will show a number of buttons to choose from. If these don't meet your needs you can always roll your own custom views, but this is more work. Apple's provided UI components are a good start.
您可以使用UIPickerView
,但听起来您更有可能在之后UIActionSheet
会显示许多可供选择的按钮。如果这些不能满足您的需求,您可以随时推出自己的自定义视图,但这需要更多的工作。Apple 提供的 UI 组件是一个好的开始。
Note: there's no Interface builder way to create a UIActionSheet, you have to do it in code, but it's pretty straight foward (see RootViewController class files in this Apple sample codeproject).
注意:没有创建 UIActionSheet 的接口构建器方法,您必须在代码中完成它,但它非常直接(请参阅此 Apple示例代码项目中的RootViewController 类文件)。
回答by Tendulkar
create a button (like dropdown button) and when you click on that button call another viewcontroller which you want to display and add it as subview to the controller.
创建一个按钮(如下拉按钮),当您单击该按钮时,调用另一个要显示的视图控制器并将其作为子视图添加到控制器中。
回答by Krishnan
Gayan, I think your question is already answered. please check this How to create dropdown box?
Gayan,我想你的问题已经回答了。请检查这个如何创建下拉框?
And as TOm H and petert mentioned , I too believe that you need to use UIPickerView.
正如 TOm H 和 petert 所提到的,我也相信您需要使用 UIPickerView。
回答by j2emanue
here is another way of doing it http://www.edumobile.org/iphone/iphone-programming-tutorials/a-simple-drop-down-list-for-iphone/
这是另一种方法http://www.edumobile.org/iphone/iphone-programming-tutorials/a-simple-drop-down-list-for-iphone/
Or here is one not everyone knows: The action sheet is basically a drop down list if you think about it. And if you keep adding buttons to a UIActionSheet it ends up turning into a table. So just have your button call a UIActionSheet.
或者这里有一个不是每个人都知道的:如果您考虑一下,操作表基本上是一个下拉列表。如果你不断向 UIActionSheet 添加按钮,它最终会变成一个表格。因此,只需让您的按钮调用 UIActionSheet。