我已将文本字段的委托(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/