UIPickerView - 1st row selection does not call didSelectRow

前端 未结 5 982
我寻月下人不归
我寻月下人不归 2020-12-09 09:46

I have a UIPickerView on my UIView along with a UITextField. I am letting the user select a value from the picker or enter a custom va

5条回答
  •  不思量自难忘°
    2020-12-09 10:23

    Can you programmatically select a row right after you instantiate the UIPickerView?

    int firstRow = 0;
    int firstOptionIndex = 0;
    [myPickerView selectRow:firstRow inComponent:firstOptionIndex animated:NO];
    

    That last line will trigger your pickerView:didSelectRow:inComponent delegate method.

    In other words, that should set the value of the variable, wherever you are storing it (NSArray? not clear).

提交回复
热议问题