在 didSelectRow 上重新加载 UIPickerView
我有一个带有多个组件/列的 UIPickerView。我希望 UIPickerView 在选择某一行时立即添加另一列。我该怎么做?
I have got a UIPickerView with multiple components/columns. I want the UIPickerView to add another column immediately when a certain row is selected. How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加一些东西到选择器视图数组。然后 [pickerview reloadAllComponents];
add something to the picker view array.Then [pickerview reloadAllComponents];
首先,当选择特定行时(您可以通过
[UIPickerViewDelegate: pickerView: didSelectRow: inComponent:]
方法检测),您必须修改 UIPickerViewDataSource 以反映添加了新列通过增加
[UIPickerViewDataSource numberOfComponentsInPickerView:]
返回的值然后,就像 Hitman 所说,
[UIPickerView重新加载所有组件]
。更多详细信息,请参阅 Apple 文档 UIPickerViewDelegate 和 UIPickerViewDataSource
First, when that certain row is selected (which you can detect via the
[UIPickerViewDelegate: pickerView: didSelectRow: inComponent:]
method)You'd have to modify your UIPickerViewDataSource to reflect that a new column is added by incrementing the value returned by
[UIPickerViewDataSource numberOfComponentsInPickerView:]
And then, like Hitman said,
[UIPickerView reloadAllComponents]
.More details can be found at Apple's documentation for UIPickerViewDelegate and UIPickerViewDataSource