Skip to content

Instantly share code, notes, and snippets.

@yimingtang
Created July 17, 2013 03:47
Show Gist options
  • Save yimingtang/6017546 to your computer and use it in GitHub Desktop.
Save yimingtang/6017546 to your computer and use it in GitHub Desktop.
@interface UIResponder (FirstResponder)
+ (id)currentFirstResponder;
@end
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment