ios 开发 收起键盘的小技巧

在UIViewController中收起键盘,除了调用相应控件的resignFirstResponder方法外,还有另外三种方法:

  • 1.重载UIViewController中的touchesBegin方法,然后在里面执行[self.view endEditing:Yes];这样单击UIViewContrloller的任意地方,就可以收起键盘。
  • 2.直接执行[[UIApplication shareApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
  • 3.直接执行[[[UIApplication shareApplication] keyWindow] endEditing:YES];

真方便

 参考:http://www.jianshu.com/p/5bd1080a1e96

原文地址:https://www.cnblogs.com/cocoajin/p/4755024.html