Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: How To Make PickerView Start At A Certain Row When It Is First Displayed

Is there a way to make the PickerView in Xcode start at a default row? Right now, my PickerView starts at the first element in my array.

So for example, if I have 1 component with 30 rows, how can I make the PickerView start at row 15 when the user first sees the PickerView?

Thanks

like image 328
John Avatar asked Feb 23 '12 00:02

John


1 Answers

use -[UIPickerView selectRow:inComponent:animated:] ... assuming you have one component, do the following:

UIPickerView *aPicker = [[[UIPickerView alloc] init] autorelease];
aPicker.delegate = self;
aPicker.dataSource = self;
aPicker.showsSelectionIndicator = YES;
[self.view addSubview:aPicker];
[aPicker selectRow:14 inComponent:0 animated:NO];
like image 67
pho0 Avatar answered Nov 08 '22 21:11

pho0