我有以下用户界面:
如果使用开关,是否可以只禁用最后两个组件?如果是这样,我该怎么做?
Best Answer-推荐答案 strong>
您不能禁用组件。不过,您可以尝试这些解决方案。
第一个解决方案:
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
}
}
关于ios - Swift UIPickerView 禁用组件,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/42853186/
|