带有iPhone下拉菜单的UITextField [英] UITextField with a dropdown menu for iPhone

查看:131
本文介绍了带有iPhone下拉菜单的UITextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个简单的方法为UITextField创建一个下拉菜单,以便用户可以键入自定义条目或从列表中选择一个?解决方案

对于下拉菜单,您可以实现UITableView。您可以使用列表填充此UItableview。



只需在ViewController的ViewDidLoad方法中声明它,然后可以稍后显示或隐藏。

  TableView = [[UITableView alloc] initWithFrame:CGRectMake(x,x,x,x)]; 
TableView.delegate = self;
TableView.dataSource = self;

当用户点击UITextField时,将其添加到主视图。

  [self.view addSubView:TableView]; 

如果您希望用户从给定列表中选择更好的选项是UIButton而不是UITextField。



编辑:我没有注意到与上述相同。


Is there an easy way to create a drop down menu for a UITextField, so that the user can type a custom entry or select one from a list?

解决方案

For drop down menu you can implement UITableView. You can populate this UItableview with your list.

Just declare it in ViewDidLoad method of your ViewController and then you can show or hid accordingly later.

    TableView = [[UITableView alloc]initWithFrame:CGRectMake(x,x,x,x) ];
    TableView.delegate = self;
    TableView.dataSource = self;

Add this to main view when user clickes on UITextField.

[self.view addSubView:TableView];

If you want user to select from given list only better option is UIButton instead of UITextField.

EDIT: I didn't notice it is the same as above answer.

这篇关于带有iPhone下拉菜单的UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆