Created
March 9, 2016 03:52
-
-
Save fhefh2015/5ce563d0c9eb2bc225b5 to your computer and use it in GitHub Desktop.
iOS关闭/收起键盘方法总结
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//点击Return按扭时收起键盘 | |
- (BOOL)textFieldShouldReturn:(UITextField *)textField | |
{ | |
return [textField resignFirstResponder]; | |
} | |
//点击背景View收起键盘(你的View必须是继承于UIControl) | |
[self.view endEditing:YES]; | |
//你可以在任何地方加上这句话,可以用来统一收起键盘 | |
[[[UIApplication sharedApplication] keyWindow] endEditing:YES]; | |
//接发送 resignFirstResponder 消息 | |
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) | |
to:nil | |
from:nil | |
forEvent:nil]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment