iOS-收起键盘

1 除了调用相应控件的resignFirstResponder方法外,还有另外三种办法:

2 重载UIViewController中的touchesBegin方法,然后在里面执行在[self.view endEditing:YES];这样单击UIViewController的任意地方,就可以收起键盘。

3 直接执行[[UIApplication sharedApplication]sendAction:@selector(resignFirstResponder)to:nil from:nil forEvent:nil];用在获得当前控制器比较困难是时候

4 直接执行[[[UIAppliction sharedApplication]keyWindow]endEditing:YES];

原文地址:https://www.cnblogs.com/linxiu-0925/p/5447464.html