How can I set UIPickerView at other than the default index?

Chatar Veer Suthar picture Chatar Veer Suthar · Feb 15, 2011 · Viewed 16.7k times · Source

I have an integer having value of 5 and I want to start my UIPickerView with this index, now what should I do? normally UIPickerView is on default 0 index row, but I want it on index which is user defined, as can be 5, 6 or any other digit.

Answer

Dan Ray picture Dan Ray · Feb 15, 2011

Assuming your picker is referred to in a property "myPicker", then in viewDidLoad, go:

[self.myPicker selectRow:rowInt inComponent:componentInt animated:NO]