隐藏键盘ios [英] hiding keyboard ios

查看:130
本文介绍了隐藏键盘ios的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个文本输入,每当我触摸背景时我都可以隐藏键盘,但只有当我进入第一个文本框时才会命名为textField1。现在这段代码应该很简单,但我似乎无法得到它,我做错了什么?

I have a few text inputs and I can hide the keyboard whenever i touch the background, but only when I have been entering into the first text box name textField1. now this code should be simple but i just cant seem to get it, what am i doing wrong??

-(IBAction)backgroundTouched:(id)sender {
[textField1 resignFirstResponder];
[buildLength resignFirstResponder];
[buildWidth resignFirstResponder];
[ridgeWidth resignFirstResponder];
[rafterWidth resignFirstResponder];
[hipWidth resignFirstResponder];
[eaveOverhang resignFirstResponder];
[spacing resignFirstResponder];

}

推荐答案

如果你想点击按钮时隐藏键盘,你的视图中有多个 UITextFields ,那么你应该使用:

If you want to hide the keyboard when you tap a button and you have more than one UITextFields in your view, then you should use:

[self.view endEditing:YES];

点按视图上的任意位置,键盘将消失。

Tap anywhere on the view, and the keyboard will disappear.

这篇关于隐藏键盘ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆