I have created UIDatePicker and added target for event UIControlEventValueChanged. Default value of the date picker is set to the current date.
Date picker is shown when I click into text field. Then user can select date, click outside the view controller with the date picker, it disappears and text field is set to the selected date.
Problem is when the user wants to select current(default) date. It is necessary to change value from and back to the default value. It is because the date picker fires UIControlEventValueChanged event. I want also to let the user decide, if he wants to fill the date value (if he just clicks outside the view control with date picker).
How is it possible to let the user select the default value of the date picker without changing the value from and back to the default value?
Is it acceptable for you to just set the date in the text field as soon as the text field is shown? That way the user doesn't need to do anything if the current date is what they want in the text field.
If the text field needs to start blank for some reason, then you could have the current date show in the text field as soon as the user first taps inside it (i.e. at the same time as you display the UIDatePicker).
If neither of these are acceptable, have you tried setting a target action for another control event, such as UIControlEventTouchDown
/ UIControlEventDragInside
/ UIControlEventEditingDidBegin
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With