1)
在UIViewController中,调用相应控件的resignFirstResponder方法
//passwordText是个UITextField
[self.passwordText resignFirstResponder];
2)
重载UiViewController中的touchesBegin方法,然后在里面执行[self.view endEditing:YES];,这样单击UIViewController是我任意地方,就可以收起键盘。
3)
直接执行[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder)to:nil from:nil forEvent:nil];,用于在获得当前UIViewController比较困难的时候用。
4)
直接执行[[UIApplication sharedApplication] keyWindow] endEditing:YES]。