How to hide the default keyboard

I have 5 UITextFields added to the form. One of the text files is for entering a date of birth. Therefore, when this particular text field is touched instead of displaying the default keyboard, the date picker should be displayed.

I tried the following:

- (void)textFieldDidBeginEditing:(UITextField *)textField{
   [textField resignFirstResponder];
   [self showDatePicker];//this is my own function to display datepicker.
}

when this function is called datepicker, it is displayed along with the date selection, the default keyboard is also displayed and hides the date. I do not know how to get rid of the default keyboard for this particular text file. Please help me.

+3
source share
5 answers

Although this is an old question, I came here when I was looking for the same thing.

/ , ,

- (void) hideKeyboard: (UIView *) view {
    NSArray *subviews = [view subviews];
    for (UIView *subview in subviews){
        if ([subview isKindOfClass:[UITextField class]]) {
            [subview resignFirstResponder];
        }
        [self hideKeyboard: subview ];
    }
}

,

[self.view endEditing:YES];
+3

-textFieldShouldBeginEditing:.

NO, .

, NO.

+2

, UITextField . UITableViewCell UIViewController datepicker .

+1

,

.

, UITextField, .inputView DatePicker

, , , .

+1

Failure from the first responder should hide the keyboard. My best guess is that textField is not really the first responder at this point in the code, so talking about resigning has no effect. You may need to insert a statement NSLogto verify this.

0
source

Source: https://habr.com/ru/post/1704815/


All Articles