-
-
Save bago2k4/04fb7210f84352b8080d to your computer and use it in GitHub Desktop.
DAKeyboardControl.m diff
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
--- a/Other Sources/DAKeyboardControl/DAKeyboardControl.m | |
+++ b/Other Sources/DAKeyboardControl/DAKeyboardControl.m | |
@@ -167,6 +167,8 @@ static char UIViewKeyboardPanRecognizer; | |
nullView.backgroundColor = [UIColor clearColor]; | |
textField.inputAccessoryView = nullView; | |
self.keyboardActiveInput = (UIResponder *)textField; | |
+ // Force the keyboard active view reset | |
+ [self inputKeyboardDidShow:nil]; | |
} | |
} | |
@@ -207,8 +209,8 @@ static char UIViewKeyboardPanRecognizer; | |
// If the active keyboard view could not be found (UITextViews...), try again | |
if (!self.keyboardActiveView) | |
{ | |
- [self.keyboardActiveInput resignFirstResponder]; | |
- [self.keyboardActiveInput becomeFirstResponder]; | |
+ // Find the first responder on subviews and look re-assign first responder to it | |
+ [self reAssignFirstResponder]; | |
} | |
} | |
@@ -289,6 +291,7 @@ static char UIViewKeyboardPanRecognizer; | |
{ | |
if(!self.keyboardActiveView || !self.keyboardActiveInput || self.keyboardActiveView.hidden) | |
{ | |
+ [self reAssignFirstResponder]; | |
return; | |
} | |
else | |
@@ -487,4 +490,28 @@ static char UIViewKeyboardPanRecognizer; | |
[self didChangeValueForKey:@"keyboardPanRecognizer"]; | |
} | |
+- (void) reAssignFirstResponder{ | |
+ // Find first responder | |
+ UIView *inputView = [self recursiveFindFirstResponder:self]; | |
+ if (inputView != nil) { | |
+ // Re assign the focus | |
+ [inputView resignFirstResponder]; | |
+ [inputView becomeFirstResponder]; | |
+ } | |
+} | |
+ | |
+- (UIView*) recursiveFindFirstResponder:(UIView*)view{ | |
+ if ([view isFirstResponder]) { | |
+ return view; | |
+ } | |
+ UIView *found = nil; | |
+ for (UIView *v in view.subviews) { | |
+ found = [self recursiveFindFirstResponder:v]; | |
+ if (found) { | |
+ break; | |
+ } | |
+ } | |
+ return found; | |
+} | |
+ | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment