You have missed assign target to UIDatePicker````. As you are passing target and selector but not assing to
UIDatePicker```
Add this line inside the setDatePickerAsInputView
function
datePicker.addTarget(target, action: selector, for: .valueChanged)
Now, dateSelected
method call everytime whenever value is changed. So, you need to remove this line self.dateTextField.resignFirstResponder()
from function. Or you can change action from .valueChanged
to .editingDidEnd
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…