运行func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
时是否可以调用UIPickerView.selectRow(4, inComponent: 0, animated: false)
方法
或者存档这个的正确方法是什么?
我的实现
let pickerView = UIPickerView()
pickerView.delegate = self
pickerView.dataSource = self
pickerView.selectRow(0, inComponent: 0, animated: false)
textField.inputView = pickerView
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
}
最佳答案
这是选择行
self.yourPickerViewName.selectRow(2, inComponent: 0, animated: true)
这将触发该方法
self.pickerView(self.yourPickerViewName, didSelectRow: 2, inComponent: 0)
组合它们以模拟用户操作