简体   繁体   English

如何在iPhone应用程序中创建下拉菜单?

[英]How do I create a drop down menu in iPhone app?

When the user taps on UITextField I want it to display a drop down menu with 5 or more options. 当用户点击UITextField时,我希望它显示一个包含5个或更多选项的下拉菜单。 When the user selects one of the options, it has to be set as the text of the text field. 当用户选择选项之一时,必须将其设置为文本字段的文本。 Any ideas on how to create it? 关于如何创建它的任何想法?

参见此示例CustomDropDownList

Create a UITableView I guess? 我猜创建一个UITableView吗? With the 5 options inside. 里面有5个选项。 Then implement the didSelectRowAtIndexPath method of the tableview to set the text inside the textfield. 然后实现tableview的didSelectRowAtIndexPath方法以在文本字段内设置文本。

您可以尝试使用UIPicker

Drop down is not available in the iphone .Though there is an option of adding picker view inside the action sheet if you are making an application on iphone. iphone中没有下拉菜单。但是,如果要在iphone上创建应用程序,则可以在操作表中添加选择器视图。 and for ipad Application put a tableview inside a popovercontroller controller. 对于ipad应用程序,将一个tableview放在popovercontroller控制器内。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM