如何不使用didSelect委托方法在选择器视图中显示字符串数组?
答案 0 :(得分:-1)
func numberOfComponents(in pickerView: UIPickerView) -> Int
{
return 1 // the amount of "columns" in the picker view
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int
{
return yourArray.count // the amount of elements (row)
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String?
{
return yourArray[row] // the actual string to display for the row "row"
}
就这么简单。无需didSelect。每当您在选择器视图中更改选择时,就会调用didSelect委托函数。您不需要那一个来显示数据