Getting selected value of a UIPickerViewControl in Swift

后端 未结 4 1181
后悔当初
后悔当初 2021-02-05 03:05

How can I get the selected value of a UIPickerViewControl in Swift?

I tried something like this:

labelTest.text = Spinner1.selectedRowInComponent(0).desc         


        
4条回答
  •  终归单人心
    2021-02-05 04:00

    Swift 3: supose you want the String value of each row selected

    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    
            let valueSelected = yourDataSourceArray[row] as String
     }
    

提交回复
热议问题