Instead of showing the keyboard, I want to display a pop-up view when selecting textField (my code is below). If the keyboard does not appear, everything works fine. However, if the keyboard is shown and then a text field is selected, the keyboard is not discarded, somewhere the first responders should get lost, but I do not know where. Anyone have a solution?
My text box:
self.startDateTextField = [[UITextField alloc] initWithFrame:CGRectMake(79, 148, 138, 27)]; [self.startDateTextField setBorderStyle:UITextBorderStyleRoundedRect]; [self.startDateTextField setDelegate:delegate]; [self.startDateTextField addTarget:delegate action:@selector(editStartDate:) forControlEvents:UIControlEventEditingDidBegin]; [popoverWrapper addSubview:self.startDateTextField];
and in editStartDate: I have:
-(void)editStartDate:(UITextField *)textField { [textField resignFirstResponder]; DatePickerVC *datePickerVC = [[DatePickerVC alloc] init]; datePickerVC.delegate = self; self.popoverController = [[UIPopoverController alloc] initWithContentViewController:datePickerVC]; [self.popoverController setDelegate:self]; [self.popoverController presentPopoverFromRect:CGRectMake(0, 0, 5, 5) inView:textField permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; }
source share