Swift 4:实现选择器视图委托:
optional public func pickerView(_ pickerView: UIPickerView, titleForRow row:
Int, forComponent component: Int) -> String?
例子:
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int,
forComponent component: Int) -> String? {
let value = dummyListArray[row]
if value == "someText"{
//Perform Action
}
return value
}
或者
optional public func pickerView(_ pickerView: UIPickerView, didSelectRow row:
Int, inComponent component: Int)
例子:
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int,
inComponent component: Int) {
let value = dummyListArray[row]
if value == "someText"{
//Perform Action
}
}