目前我在 iPhone 应用程序中工作,使用 UITextField 输入电话号码,用户输入电话号码,那么如何隐藏键盘?因为这里没有返回按钮,是否可以在键盘内添加完成按钮,请帮助我
提前致谢

目前我在 iPhone 应用程序中工作,使用 UITextField 输入电话号码,用户输入电话号码,那么如何隐藏键盘?因为这里没有返回按钮,是否可以在键盘内添加完成按钮,请帮助我
提前致谢

这是一个很好的教程。
您可以使用“应用”和“取消”按钮添加 inputAccessoryView,然后关闭数字键盘。
输入附件视图
- (void)viewDidLoad
{
    [super viewDidLoad];
    UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
    numberToolbar.barStyle = UIBarStyleBlackTranslucent;
    numberToolbar.items = [NSArray arrayWithObjects:
                         [[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelNumberPad)],
                         [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                         [[UIBarButtonItem alloc]initWithTitle:@"Apply" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)],
                     nil];
    [numberToolbar sizeToFit];
    numberTextField.inputAccessoryView = numberToolbar;
}
-(void)cancelNumberPad{
    [numberTextField resignFirstResponder];
    numberTextField.text = @"";
}
-(void)doneWithNumberPad{
    NSString *numberFromTheKeyboard = numberTextField.text;
    [numberTextField resignFirstResponder];
}
在不使用完成按钮的情况下,您也可以通过触摸视图上的任何位置以这种方式隐藏数字键盘
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [yourtextfieldname resignFirstResponder];
}