UITextField 和 UIPickerView
当选择 UITextField 时,是否可以显示 UIPickerView 而不是键盘? Interface Builder 中的每个选项都是某种键盘。
我想我可以以编程方式创建一个 UIPickerView 并在 UITextField 注册 touchUpInside 事件时创建一个 UIPickerView,然后告诉 UITextField resignFirstResponder,但这似乎有点黑客。
有没有“官方”或更“正确”的方法来做到这一点?
谢谢!
Is it possible for a UIPickerView to appear instead of a keyboard when a UITextField is selected? Every option in Interface Builder is some sort of keyboard.
I suppose I could create a UIPickerView programmatically and create one when the UITextField registers a touchUpInside event, then tell the UITextField to resignFirstResponder, but that seems a bit of a hack.
Is there an "official" or more "correct" way to do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以实现此代码并覆盖默认行为(即显示键盘):
您不妨显示自己的 UIPickerView 并执行您的操作,而不是显示 UIAlertView。
You can implement this code and override the default behaviour (that is, showing the keyboard):
Instead of showing a UIAlertView, you might as well show your own UIPickerView and do your thing.