点击“完成”时如何获取 uipickerview 中当前选定的行(具有多个选择器)
我的应用程序中的 UIPickerview
工作正常。
我想更改 UIPickerview
的默认选择行为,我的意思是我在 UIToolbar
中有一个完成按钮。工具栏已添加到 UIPickerview
中。
每当用户点击“完成”按钮时,我想将突出显示的条目视为已选择。 这意味着用户可以上下移动,当用户点击“完成”按钮时,我想现在考虑选择
请告诉我,如何获取 UIPickerview
当前选定的行当点击“完成”按钮时
注意:我的视图中有 3 个选择器(我的意思是我想要 pickerview 标签和 pickerview 选定的行)
I have got UIPickerview
in my application working fine.
I want to change the default selection behavior of the UIPickerview
, i mean i have a done button in the UIToolbar
. The toolbar is added to the UIPickerview
.
Whenever the user taps on the "Done" button, I want to consider the highlighted entry as selected.
That means user can move up and down , when the user taps on the "Done" button, i want to consider the selection now
Please let me know , how can I fetch the currently selected row for the UIPickerview
when tapped "Done" button
Note: I have 3 pickers in my view ( i mean i want to have pickerview tag and pickerview selected row)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
//假设您创建了三个选取器视图,分别为firstPickerView、secondPickerView和ThirdPickerView
//Suppose you have created three picker views as firstPickerView, secondPickerView and ThirdPickerView
selectedRowInComponent:
参数
组件
标识选取器视图组件的零索引数字。
返回值
标识所选行的零索引数字,如果没有选择行,则为 -1。
寻求帮助
并制作不同 pickerView 之间的差异为每个选择器添加标签:
希望这有帮助。
selectedRowInComponent:
Parameters
component
A zero-indexed number identifying a component of the picker view.
Return Value
A zero-indexed number identifying the selected row, or -1 if no row is selected.
For Help
And to make a difference between different pickerViews add tag to each of the pickers:
Hope this helps.
现在 str 有一个选定的值。这样您就可以在按下按钮后使用它。
now str have a selected value. so you can use it when done button press.
以下是 UIPickerview 控制器
.m 文件
和 .h 文件的示例,
祝您编码愉快
@塞缪尔
Following example for the UIPickerview controller
.m files here
and .h file here
happy coding
@samuel