var selectedRow3 = 3
var selectedRow4 = 3
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
switch component {
case 3:
myPicker.selectRow(selectedRow3, inComponent: component, animated: true)
case 4:
myPicker.selectRow(selectedRow4, inComponent: component, animated: true)
default:
break
}
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
switch component {
case 3:
return 1
case 4:
return 1
default:
return 10
}
}
您无法禁用组件。但是,您可以使用reloadAllComponents
方法重新加载选择器,并且应该仅重新加载所需的组件。不要加载时间组件。