如何从视图中解开键盘? [英] How to dismiss the keyboard from the view?

查看:52
本文介绍了如何从视图中解开键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以编程方式创建了文本字段以获取其中的值.一旦我在文本字段中获得了值,我就想关闭键盘.

I created the textfield programmatically for getting the value in it. Once i got the value in the textfield i wanted to dismiss the keyboard.

有人可以通过示例代码帮助我吗?

Could anyone help me in this with sample code?

谢谢.

推荐答案

如果您询问iOS的键盘,则可以执行以下操作:

If you are asking about iOS' keyboard, then you can do this:

[textField resignFirstResponder];

UITextField 获得焦点时,它被称为获得了第一响应者状态",这意味着它是响应者链中的第一个 UIResponder /em>.这对您意味着什么,当您将 resignFirstResponder 消息发送到 UIResponder 时,接收者将从弹出的响应者链中弹出,并且该链中的下一个响应者将首先获得响应者状态.

When a UITextField gains focus, it is said to have "gained first responder status", meaning that it is the first UIResponder in the responder chain. What this means to you is that when you send the resignFirstResponder message to a UIResponder, the receiver will be popped off the responder chain and the next responder in the chain will gain first responder status.

这篇关于如何从视图中解开键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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