Skip to content

Instantly share code, notes, and snippets.

@justinHowlett
Last active December 18, 2015 18:40
Show Gist options
  • Save justinHowlett/5827443 to your computer and use it in GitHub Desktop.
Save justinHowlett/5827443 to your computer and use it in GitHub Desktop.
Resign the keyboard no matter where it is in the application. (I usually wrap my utility methods in a C function)
void globalResignKeyboard(void){
UIWindow * window = [[UIApplication sharedApplication] keyWindow];
for (UIView * view in [window subviews]){
resignKeyboardInSubviewsOfView(view);
}
}
void resignKeyboardInSubviewsOfView(UIView* view){
if ([view respondsToSelector:@selector(resignFirstResponder)]){
[view resignFirstResponder];
}
for (UIView * subview in [view subviews]){
resignKeyboardInSubviewsOfView(subview);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment