-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Make IQ work when keyboard is already shown #5
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
Conversation
Make IQKeyboard work when the keyboard is already shown and the UITextField/UITextView becomes first responder (in this case UIKeyboardWillShowNotification is not fired). Also IQ before this change didn't work for me for UITextView (worked only for UITextField). After the change IQ is working well both for UITextField and UITextView.
Hi mrvincenzo, First I clarify that UIKeyboardWillShowNotification is also fired when Any UITextField/UITextView becomes first responder. For more information see 'IQKeyBoardManager.m'. I have added a NSNotification control flow chart for you. Second thing I forgot to write this code on 'textViewDidBeginEditing'. I only added this code on textFieldDidBeginEditing. This was my mistake.
I Think this issue has been fixed now. Please review code once again, and comment back, if I didn't understand exact issue or issue has not been fixed. I have pushed my updated code. Thanks |
Hi Iftekhar, I thought that you probably missed the code you mentioned for textViewDidBeginEditing that's why I moved it to a separate method that is called both for UITextField and UITextView. As for the UIKeyboardWillShowNotification - I had two issues with it. First is that for me, in case of UITextView, the notification was fired before the delegate call to textViewDidBeginEditing. Therefore, the UITextView frame wasn't adjusted at all. I tested it on iOS 6. Second is that when the keyboard is already shown for UITextField/View X, and UITextField/View Y became the responder, the keyboard remains and the UIKeyboardWillShowNotification is not fired. Like with the first issue, the frame of Y is not adjusted at all. Another issue that I saw but didn't have a chance to look in is that when you constantly switched between 2 UITextField/UITextView the frame was not restored correctly. In my case one was UITextField (say X) and the other was UITextView (say Y). I tapped on the X, on Y, on X, on Y and so on. Zeroing the keyboardDistanceFromTextField variable fixed the issue for me but it is a patch and not a real fix. Regards, |
Hi mrvincenzo, Again very very thanks for your bug report and help me to improve IQKeyboardManager. Regards |
Hi Iftekhar, I also found this issue that however, for UITextView, the notification sequence is the following, This is why your UITextField works well, but UITextField not. The easiest way to solve it, I change ``UIKeyboardWillShowNotification Hope this helpful. Thanks & Regards |
plus: I also agree @mrvincenzo . For |
OK, now i understand the issue behind this. @heefan i merged your pull request. I think it should work fine now. @mrvincenzo Again thanks for the bug report. |
Good job nailing it. Still there is a bug I described in detail in my previous comments. My original pull request had a fix for this issue. When a keyboard already shown for some |
Hi @mrvincenzo , The latest code does not have |
The bug is still there. My bad, I meant |
We need to manage it somehow. Without that i think it is not possible to maintain it automatically. |
Exactly. Thats what I am doing in my fork. You can compare your IQKeyboardManager.m and the one from my fork. In your demo, the
in I suggest the following logic - when the
It is already working in my fork. I can send a pull request if you want. |
ok, please send me pull request of your repository. |
Hi @mrvincenzo, I probably miss some cases. Thanks for pointing out this issue. |
I noticed that, when UIKeyboard doesn't have any inputAccessoryView then keyboardWillShow and keyboardDidShow doesn't called. This may be a case for IQKeyboardManager. |
I also updated iOS NSNotification Machanism for textView. I Observed that, when beginning textField, or switching between textFields, the notification mechanism is almost same. But when we begin textView Editing or switching between them the notification mechanism is very different from textField even if between textView (Beginning/Switching). |
Finally fully functional with UITextView. |
Make IQKeyboard work when the keyboard is already shown and the UITextField/UITextView becomes first responder (in this case UIKeyboardWillShowNotification is not fired). Also IQ before this change didn't work for me for UITextView (worked only for UITextField). After the change IQ is working well both for UITextField and UITextView.