ios - 键盘消除问题 - Objective C

标签 ios textfield

我已将文本字段的委托(delegate)设置为 self,并在 .h 中添加了它的委托(delegate),但我遇到了问题。如果我单击 View 中除文本字段之外的任何内容,我希望键盘隐藏。这可能吗?如果是这样,我该怎么做?

最佳答案

我找到了一种更简单的隐藏键盘的方法,当您单击屏幕方式时它就可以工作。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    // endEditing: This method looks at the current view and its subview hierarchy for the text field that is currently the first responder.
    // If it finds one, it asks that text field to resign as first responder
    [[self view] endEditing:TRUE];
}

关于ios - 键盘消除问题 - Objective C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6796287/

相关文章:

c++ - 从 WinApi 中的可编辑文本字段读取数据

java - 将图像和文本字段放在同一类中

ios - 使用具有多个文本字段的键盘时如何防止 View 向上移动额外空间

ios - 通过委托(delegate)选择 TableView 行是选择多行而不是一行

ios - 在 Swift 中上传带有参数的图像

ios - 有没有办法以编程方式拒绝 GameKit 中的回合制比赛?

java - 从文件中读取数据到 Textfields java

ios - iPad Mini 上 GCD 后台队列挂起时的 CoreData 保存

ios - UIActionSheet 在 iOS7 中缺少背景

java - 如何将文本字段中的 double 值转换为字符串