Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
Created March 9, 2016 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhefh2015/5ce563d0c9eb2bc225b5 to your computer and use it in GitHub Desktop.
Save fhefh2015/5ce563d0c9eb2bc225b5 to your computer and use it in GitHub Desktop.
iOS关闭/收起键盘方法总结
//点击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