iPhone:多个 UIPickerView
我在 iPhone 应用程序中使用多个 UIPickerView
。我的问题是,如何处理多个 UIPickerView 处理事件?
另外,我想将选定的值放置在不同 UIPickerViews
的 UITextField
中。
I use a multiple UIPickerView
in iPhone application. My question is, how can I handle multiple UIPickerView
Handle Events?
Also, I want to place the selected value In UITextField
of different UIPickerViews
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在每个委托中,您都有触发委托的
UIPickerView
的引用。例如:您有 thePickerView 变量指向响应此操作的控件,您现在需要做的就是区分您的
UIPickerViews
如下:或者使用 Tag 属性
我会选择标签解决方案;比较 int 更快。
如何获取所选值:
至于
UIPickerView
的所选值,您可以使用委托来实现:您将需要使用这里使用相同的技术;区分您的
UIPickerView
并获取该数据源的选定行,然后就完成了In each delegate you have reference of the
UIPickerView
which got triggered the delegate. for instance:You have thePickerView variable which points to the control responded to this action, all you need to do now is to distinguish between your
UIPickerViews
as the following:Or Using The Tag property
I would go with the tag solution; comparing
int
is way faster.How do I get the selected value:
As for the selected value of
UIPickerView
you can do that by using the delegate:You will need to use the same technique here; distinguish between your
UIPickerView
and get the selected row for that data source and you are done