Hi I am using picker view
, by default it is selecting the first row. I don\'t want this option. For example I am having \"No\" and \"yes\" options.If i give this op
If you want to get this one by using UIPickerView
then pass the first component
of the picker view as a empty value,otherwise you can use custom pickerview
.
[pickerArray addObject:@""];//first element of the picker component.
if you need to show selection indicator only on row selection from picker view
when dragging it on xib set its behavior in right pane uncheck the "shows selection indicator" and then in this method
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
PickerSamples.showsSelectionIndicator=YES;
}
here picker samples is my picker.....
In the viewDidLoad
add this line
[picker selectRow:**selectedRow** inComponent:0 animated:YES];
Note:selectedRow is the row number which you want to show as selected.
This works for me
[picker selectRow:-1 inComponent:0 animated:NO];
You can't do deselecting all the rows in uipickerview.
One thing you can do is create an additional row(eg: Select Option) in the top and default selection change to that row. Dont forget to change in your delegate method.