我正在使用选择器视图从数组中选择一个值,并将其保存到数据库中。下次用户进入选择器视图“字段”时,我想将突出显示的选择器设置为保存到数据库的值。我怎么做 ?
问问题
173 次
1 回答
0
您可以使用以下方法-selectRow:inComponent:animated:
:UIPickerView
// I suppose that you have such variables and one component
UIPickerView *pickerView;
NSArray *variants;
id userVariant = // get variant from db
NSUInteger row = [variants indexOfObject:userVariant];
if (row != NSNotFound) {
[pickerView selectRow:[variants indexOfObject:userVariant] inComponent:0 animated:YES];
}
于 2013-10-20T07:13:36.387 回答