Skip to content

Instantly share code, notes, and snippets.

@jrturton
Created June 28, 2013 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrturton/5883694 to your computer and use it in GitHub Desktop.
Save jrturton/5883694 to your computer and use it in GitHub Desktop.
Universal first responder. Credit to http://stackoverflow.com/a/14135456/852828
#import "UIResponder+FirstResponder.h"
static __weak id currentFirstResponder;
@implementation UIResponder (FirstResponder)
+(id)currentFirstResponder {
currentFirstResponder = nil;
[[UIApplication sharedApplication] sendAction:@selector(findFirstResponder:) to:nil from:nil forEvent:nil];
return currentFirstResponder;
}
-(void)findFirstResponder:(id)sender {
currentFirstResponder = self;
}
@end
@jrturton
Copy link
Author

If you like this, please upvote the original author here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment