[textField resignFirstResponder]
Unfortunately for developers, there is no Done button on the numeric keypad, its place is generally empty , and therefore, you can remove the keyboard only by calling this method. Before the release of versions iOS 3.2 and 4.0, this was solved by adding a button to this place (the method was rather dirty, but it worked and everyone was happy): neoos .
UIButton* btnInvisible;
#pragma mark -
#pragma mark UITextField delegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
//Create button
btnInvisible = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 320, 240)];
[btnInvisible addTarget:self action:@selector(hideKeyboard) forControlEvents:UIControlEventTouchDown];
//Show over the window view, which is at index 0 (usually)
CorreasAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.window insertSubview:btnInvisible atIndex:1];
return YES;
}
- (void)hideKeyboard
{
//Hide keyboard
[quantityField resignFirstResponder];
//Hide and release button
[btnInvisible removeFromSuperview];
[btnInvisible release];
}
Source: https://habr.com/ru/post/100498/