Skip to content

Instantly share code, notes, and snippets.

@florianbachmann
Created February 8, 2014 21:35
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 florianbachmann/8890708 to your computer and use it in GitHub Desktop.
Save florianbachmann/8890708 to your computer and use it in GitHub Desktop.
#import "UIResponder+FirstResponder.h"
//http://stackoverflow.com/a/14135456/202151
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment