如何根据另一个选择器的选择更改选择器行?
我有两个选择器 - 国家和地区。我需要根据国家/地区选择器中选择的行填充区域选择器。我有数组来填充两个选择器。我需要一些帮助来根据国家/地区选择器的选择更改区域选择器的行。任何帮助将不胜感激。预先非常感谢。
I have two pickers - country and region. I need to populate the region picker based on the row selected in the country picker. I have arrays to populate both the pickers. I need some help to change the rows of region picker based on the country picker's selection. Any help would be greatly appreciated. Thanks a lot in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好的,您有两个选择器,例如“countryPicker”和“regionPicker”。
在 UIPickerView 的委托方法中添加一个条件
我希望这可以解决您的问题:)
BR,哈里
Ok You have two pickers lets say countryPicker and regionPicker.
in the delegate method for UIPickerView add one condition
I hope this solves your problem :)
BR, Hari
它们是单独的选择器视图,还是具有两列的一个选择器视图?
无论哪种方式,当您更改一个选择器中的值时,只需在另一个选择器上调用 reloadAllComponents (或 reloadComponent:如果您使用的是拆分选择器),然后当它从其数据源重新加载数据时,您可以使用第一个选择器中的值选择器提供正确的区域列表。
Are they separate picker views, or one picker view with two columns?
Either way, when you change the value in one picker, just call reloadAllComponents on the other picker (or reloadComponent: if you are using a split picker) and then when it reloads the data from it's data source you can use the value from the first picker to supply the correct region list.
我的建议是,请在一个具有两个组件(国家、地区)的选择器中维护国家和地区。如果您这样做,那么我们可以根据另一个组件值更改一个组件值。
My suggestion is please maintain the country and region in one picker with two components(country,region).If u do like this then we can change the one component values based on another component value.
这将为您提供用户在国家/地区选择器中所选行的标题,
然后使用您必须填充区域名称的数组
使用
您可以在 RegionPicker 上
This will give you the title for the selected row by the user in country picker
then using the arrays you have to populate names of regions
You can use
on the RegionPicker