Monotouch:如何在UIPickerView中设置所选项目?

时间:2020-12-15 15:05:19

I've successfully created a UIPickerView and am using a custom ListModel tu supply the selectable items. But how can I specify which of the items should be selected when the view appears?

我已成功创建了UIPickerView,并使用自定义ListModel tu提供可选项。但是,如何在视图出现时指定应选择哪些项目?

Thanks,

Adrian

1 个解决方案

#1


18  

You have to call the picker view's Select method:

您必须调用选择器视图的Select方法:

pickerView.Select(1, 0, true);

This will select the second row (index 1) of the first component (index 0). The boolean is for animating the selection or not.

这将选择第一个组件的第二行(索引1)(索引0)。布尔值用于动画选择或不动画。

See the documentation.

请参阅文档。

#1


18  

You have to call the picker view's Select method:

您必须调用选择器视图的Select方法:

pickerView.Select(1, 0, true);

This will select the second row (index 1) of the first component (index 0). The boolean is for animating the selection or not.

这将选择第一个组件的第二行(索引1)(索引0)。布尔值用于动画选择或不动画。

See the documentation.

请参阅文档。