I have a view with two UITextField
controls, one to let the user to set a start date and another to set an end date. I'd like to present modally a view with a calendar to pick a date when a text field is tapped, instead of its default behavior of showing the keyboard and letting the user to tap whatever text. Then, once a date has been selected from the calendar and the calendar has been dismissed, show such date in the textfield with date format. I've been looking for some posts regarding this, like this one: Show datepicker on textfield tap, but they are a bit old posts or not resolved or answers doesn't fit my needs...
I need to support iOS 7
and above.
Could somebody help me with this?
Thanks in advance
You should look at the UITextFieldDelegate
protocol.
Specifically,
-(BOOL)textFieldShouldBeginEditing:(UITextField * _Nonnull)textField
Just present your view controller, do whatever you need to do, then return NO.
If you don't absolutely need to be using a UITextField, I would recommend using a UILabel with a UITapGestureRecognizer.