Swift: How to set a default Value of a UIPickerView with three components in Swift?

前端 未结 4 1672
一向
一向 2020-12-13 18:03

How do I set the starting row of the picker view in Swift? I see there is a code for Objective C, but I don\'t understand it. If anyone could explain how I can translate th

4条回答
  •  执念已碎
    2020-12-13 18:52

    Default value selected in pickerview in swift 3

    If Your array like bellow

    let pickerArray  = [
            ["displayValue":"--Select--" as AnyObject,"id":"" as AnyObject],
            ["displayValue":"Jame" as AnyObject,"id":"100" as AnyObject],
            ["displayValue":"Enamul" as AnyObject,"id":"201" as AnyObject]
        ]
    

    Just add bellow line for default selected in pickerview

     pickerViewTextField.text  = pickerArray[0]["displayValue"] as! String
    

提交回复
热议问题