如何在“完成/返回”时隐藏文本框键盘按下按钮Xcode 4.2 [英] How to hide Textbox Keyboard when "Done / Return" Button is pressed Xcode 4.2
本文介绍了如何在“完成/返回”时隐藏文本框键盘按下按钮Xcode 4.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Interface Builder中创建了一个文本字段。我将它的返回键设置为完成。这只是一行输入(因此它不需要多行)。
I created a Text Field in Interface Builder. I set it's "Return Key" to Done. This is a one line only input (so it wont need multiple lines).
当用户点击完成按钮时,如何隐藏虚拟键盘?
How do I hide the virtual keyboard when the user taps the done button?
推荐答案
实施委托方法 UITextFieldDelegate
,然后:
- (void)viewDidLoad {
[super viewDidLoad];
self.yourIBtextField.delegate = self;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
这篇关于如何在“完成/返回”时隐藏文本框键盘按下按钮Xcode 4.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文