Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAKeyboardControl.m -inputKeyboardDidShow: (lines # 208-212) #9

Closed
bago2k4 opened this issue Sep 11, 2012 · 3 comments
Closed

DAKeyboardControl.m -inputKeyboardDidShow: (lines # 208-212) #9

bago2k4 opened this issue Sep 11, 2012 · 3 comments

Comments

@bago2k4
Copy link

bago2k4 commented Sep 11, 2012

I have a view with a UITextField and a UITextView, these are always visible also with the keyboard opened. If i select the UITextField is all ok, i can write in that field. If after i select the UITextView, with these lines of code, you are focusing again on the old UITextField (not on the text view i selected). I think this goes in conflict with the system focus on the right responder so i see the cursor blinking on the UITextView (right) but i'm writing on the UITextField (wrong).
The main problem i think is with the UITextView, this type of responder sends the UIKeyboardDidShowNotification notification before of the UITextViewTextDidBeginEditingNotification notification.

thank you

PS: i like the way you implemented the keyboard panning gesture.

@danielamitay
Copy link
Owner

Err I'll see what I can do.

The -inputKeyboardDidShow method is in there to rectify the situation where the UIResponder has a nil inputAccessoryView (which prevents DAKeyboardControl from finding the keyboard view).

I remember this issue, but thought I fixed it. Will look again.

@bago2k4
Copy link
Author

bago2k4 commented Sep 12, 2012

thanks for your reply. To fix it i added 2 methods to DAKeyboardControl.m:

- (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;
}

and i replaced the lines 210 and 211 with this line:

[self reAssignFirstResponder];

but this works only if the responder is under self.
I also put some other changes, here a diff if you need:
https://gist.github.com/04fb7210f84352b8080d

@danielamitay
Copy link
Owner

Thanks for pointing this out, as well as your solution. Apologies for taking so long!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants