Created
October 1, 2014 07:46
-
-
Save Ashton-W/cb1242c944666219087c to your computer and use it in GitHub Desktop.
UIResponder (FirstResponder) magic. Intercept UIControls calling `sendAction:to:from:forEvent:` and store a weak ref.
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
@implementation UIResponder (FirstResponder) | |
static __weak UIResponder *currentFirstResponder; | |
+ (instancetype)currentFirstResponder | |
{ | |
[[UIApplication sharedApplication] sendAction:@selector(findCurrentFirstResponder:) to:nil from:self forEvent:nil]; | |
return currentFirstResponder; | |
} | |
- (void)findCurrentFirstResponder:(id)sender | |
{ | |
currentFirstResponder = self; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment