How to deleselect a row from UIPickerview

后端 未结 5 1381
死守一世寂寞
死守一世寂寞 2021-01-25 04:36

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

相关标签:
5条回答
  • 2021-01-25 05:05

    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.
    

    enter image description here

    0 讨论(0)
  • 2021-01-25 05:10

    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.....

    0 讨论(0)
  • 2021-01-25 05:11

    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.

    0 讨论(0)
  • 2021-01-25 05:11

    This works for me

    [picker selectRow:-1 inComponent:0 animated:NO];
    
    0 讨论(0)
  • 2021-01-25 05:26

    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.

    0 讨论(0)
提交回复
热议问题