Easier Keyboard Hiding

Most iOS tutorials will tell you to call on resignFirstResponder the control that is the first responder to get rid of the keyboard. This isn't always simple.

The easier way is to call endEditing:YES on the view that contains the control that is first responder.

 

 If you globally want to kill keyboards you can even just call it on the window like this.

UIWindow* window = [UIApplication sharedApplication].keyWindow;

if (!window) {

window = [[UIApplication sharedApplication].windows objectAtIndex:0];

}

[window endEditing:YES];