Last active
December 18, 2015 18:40
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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