Open oniikal3 opened 6 years ago
@oniikal3 Every time you change the picker Action return index (column: Int, row: Int)
, so you can easily get necessary value using switch
:
switch index.column:
case 1:
//...
case 2:
//...
I have achieved this behaviour by editing the class PickerViewViewController
here is my code
this is my implementation of the pickerView
let pickerViewSelectedValue: [PickerViewViewController.Index] = [(column: 0, row: month-1), (column: 1, row: yearIndex)]
alert.addPickerView(values: pickerViewValues, initialSelection: pickerViewSelectedValue) { vc, picker, index, values in
self.month = picker.selectedRow(inComponent: 0)+1
self.year = Int(years[picker.selectedRow(inComponent: 1)])!
}
this is the change i have made in PickerViewViewController
blue lines indicates the changes.
@dillidon As question. I need to set multiple initial selection in picker view. I have used it with 2 pickers so I have 2 values but I can only set selection for 1 column.
How can I set multiple selection. Is it possible?