Created
January 31, 2014 17:21
-
-
Save steipete/8737196 to your computer and use it in GitHub Desktop.
Getting the first responder... Unless you want to use the private [view firstResponder] this seems to be the only legal way. Or am I wrong?
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
UIView *PSPDFFindFirstResponderBeneathView(UIView *view) { | |
// Stop if e.g. we show an UIAlertView with a text field. | |
if (UIApplication.sharedApplication.keyWindow != view.window) return nil; | |
// Search recursively for first responder. | |
for (UIView *childView in view.subviews) { | |
if ([childView respondsToSelector:@selector(isFirstResponder)] && childView.isFirstResponder) return childView; | |
UIView *result = PSPDFFindFirstResponderBeneathView(childView); | |
if (result) return result; | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @steipete,
Just wanted to make sure, the link you provided makes use of the "findFirstResponder" action.. Is this not a private API? I can only find mention of it in Apple's macOS documentation, not iOS.
Thx!
Alex