如何在编辑UITextField时关闭键盘 [英] How do you dismiss the keyboard when editing a UITextField
本文介绍了如何在编辑UITextField时关闭键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道当我想关闭键盘时,我需要告诉我的UITextField来退出第一个响应者,但我不知道如何知道用户何时按下了键盘上的完成键。是否有可以监视的通知?
I know that I need to tell my UITextField to resign first responder when I want to dismis the keyboard, but I'm not sure how to know when the user has pressed the "Done" key on the keyboard. Is there a notification I can watch for?
推荐答案
我设置 UITextField
到我的 ViewController
类。
在该类中,我实现了以下方法:
In that class I implemented this method as following:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
这篇关于如何在编辑UITextField时关闭键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文