xcode 将数据重新加载到 UIPickerView

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10669861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:22:13  来源:igfitidea点击:

Reload data into UIPickerView

iosxcodeuipickerview

提问by Thomas_LEB

i need to refresh the data in the UIPickerView. i'm using

我需要刷新 UIPickerView 中的数据。我正在使用

[pickerView reloadAllComponents];

but my problem is that i need to reset the selected row as well, i want the selected row to go back to index 0, at the moment it is staying at the same index as it was before calling the reloadAllComponents function

但我的问题是我还需要重置所选行,我希望所选行返回索引 0,此时它保持与调用 reloadAllComponents 函数之前相同的索引

can anyone help please??

有人可以帮忙吗??

回答by rooster117

[pickerView selectRow:0 inComponent:0 animated:YES];

should do it

应该做