-1
我有一個UIpicker模態窗口。一切工作正常,除了一件事。當用戶單擊輸入文本字段時,帶有UIpickerView的模式窗口按預期打開。如果所選的行是正確的,並且用戶單擊確定按鈕,則當前代碼無法註冊該值。UIPicker - 如何記錄標準selectedRow如果用戶只點擊確定按鈕
// Set the default row, so if user click ok without changing it is recorded
self.picker.selectRow(0, inComponent: 0, animated: false)
是否有替代didSelectRow?我認爲這是問題,因爲用戶不會選擇一行,因爲它已經被代碼預選。
// Capture the picker selection
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
// This method is triggered whenever the user makes a change to the picker selection.
// The parameter named row and component represents what was selected.
selectedType = pickerData[row] as String
}
有時甚至最明顯的是很難看到.... –