如何在不使用didSelect委托方法的情况下在选择器视图中显示字符串数组?
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委托函数。您不需要那个用于显示数据