Skip to content

Instantly share code, notes, and snippets.

@alanthonyc
Created February 14, 2014 02:09
Show Gist options
  • Save alanthonyc/8994620 to your computer and use it in GitHub Desktop.
Save alanthonyc/8994620 to your computer and use it in GitHub Desktop.
@implementation UIView (FindFirstResponder)
- (id)findFirstResponder
{
if (self.isFirstResponder) {
return self;
}
for (UIView *subView in self.subviews) {
id responder = [subView findFirstResponder];
if (responder) return responder;
}
return nil;
}
@end
// Or...
UIView *firstResponder;
for (UIView *view in self.view.subviews) //: caused error
{
if (view.isFirstResponder)
{
firstResponder = view;
break;
}
}
@alanthonyc
Copy link
Author

From SO

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