I've implemented the IQKeyboardManager framework to make the keyboard handle easier. It works very fine, except for one thing :
There're some UItextField controls in my app which open a UIDatePicker in place of a default keyboard (e.g. number pad, decimal pad, ASCII capable, etc.).
Here's a code sample with the graphical result :
// Create the datePicker
UIDatePicker *birthdayDatePicker = [UIDatePicker new];
[birthdayDatePicker setDatePickerMode:UIDatePickerModeDate];
// Assign the datePicker to the textField
[myTextField setInputView:birthdayDatePicker];
My question is : Is it possible to handle the action on the "OK" button to fill the field "Date de naissance" ?

EDIT :
For the ones who want to know how I solved my problem :
in my .h, I imported
IQDropDownTextField.h:#import "IQDropDownTextField.h"in the .h, I changed the type of my
UITextFieldtoIQDropDownTextField:@property (weak, nonatomic) IBOutlet IQDropDownTextField *myTextField;select your field in Interface Builder or in your .xib, and show the Identity Inspector : change your field's class to
IQDropDownTextField.
Note according to Mohd Iftekhar Qurashi comment : the two next points can be avoided with the following code :
// Set myTextField's dropDownMode to IQDropDownModeDatePicker
myTextField.dropDownMode = IQDropDownModeDatePicker;
// Create a dateFormatter
NSDateFormatter *df = [NSDateFormatter new];
[df setDateFormat:@"dd/MM/yyyy"];
// Assign the previously created dateFormatter to myTextField
myTextField.dateFormatter = df;
// Assign a minimum date and/or maximum date if you want
myTextField.minimumDate = [NSDate date];
myTextField.maximumDate = [NSDate date];
// That's all !
in the .m, I added the
setCustomDoneTarget:action:method :// Create the datePicker UIDatePicker *birthdayDatePicker = [UIDatePicker new]; [birthdayDatePicker setDatePickerMode:UIDatePickerModeDate]; // Assign the datePicker to the textField [myTextField setInputView:birthdayDatePicker]; // Just added this line [myTextField setCustomDoneTarget:self action:@selector(doneAction:)];in the .m, I added the
doneAction:method :- (void)doneAction:(UITextField *)textField { [myTextField setText:[DateHelper getStringFromDate:birthdayDatePicker.date format:@"dd/MM/yyyy" useGmt:NO]]; // getStringFromDate:format:useGmt: is a method to convert a NSDate to a NSString according to the date format I want }