Reputation: 1454
I use four textFields on one page. For the first and second textFields I use regular keyboard. The third and forth are for time value - I use programmatically created DatePicker and set it via textField.inputView in the IBAction method.
The point is that my DatePicker is shown on the second time only - regular keyboard is called first time instead.
It happens only once - when I open page and click on the text field with time value the very first time. When I tap on this text field second time - it's works fine (my datepicker is shown)
How can I fix that?
The code example:
- (IBAction)wakeUpWeekdaysPressed:(id)sender {
UIDatePicker *timePicker = [[UIDatePicker alloc] init];
timePicker.datePickerMode = UIDatePickerModeTime;
UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44)];
UIBarButtonItem* doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(weekdaysTimePickerDoneAction:)];
UIBarButtonItem* cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(weekdaysTimePickerCancelAction:)];
UIBarButtonItem* flexibleSpace = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[toolbar setItems:@[cancelButton, flexibleSpace, doneButton]];
// toolbar.barStyle = UIBarStyleBlackTranslucent;
toolbar.translucent = YES;
[_wakeUpTimeWeekdays setInputView:timePicker];
[_wakeUpTimeWeekdays setInputAccessoryView:toolbar];
}
Upvotes: 1
Views: 352
Reputation: 1454
I solved the issue another way.
The DatePicker was being initialized in IBAction method for text field.
The root cause of main issue was that I selected sent event type for method Editing Did End
. So I changed sent event into Editing Did Begin
.
Now it works fine. Thank you.
Upvotes: 1