关闭键盘的几种方法

1、首先我们可以直接调用:[[[UIApplication sharedApplication] keyWindow] endEditing:YES];  在任何地方都能收起键盘。

2、点击Return按扭时收起键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    return [textField resignFirstResponder];
}

3、 还有一个方法是直接发送 resignFirstResponder 消息:
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];

posted @ 2016-09-07 10:25  Toney-c  阅读(933)  评论(0编辑  收藏  举报