24

I'm trying to move the view up when the keyboard pops up over the UITextfield which is placed on UIScrollView. I'm using UIKeyboardWillShowNotification and UIKeyboardWillHideNotification for this.

It's working perfectly when using iOS Keyboard where I'm getting the height 297.

My client is using the Gboard keyboard, he complained that the view is not moving. When I tested, I'm getting the keyboard height as 44.

I've tried both keys UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey for the NSNotifiction userInfo object. Both are giving 44 only.

I tried with UIKeyboardDidShowNotification and UIKeyboardDidHideNotification also, still same issue.

Could anyone help me with this..?

Shehan Dhaleesha
  • 627
  • 1
  • 10
  • 30
arthankamal
  • 6,341
  • 4
  • 36
  • 51
  • 1
    Have a look at this post: https://stackoverflow.com/questions/28813339/move-a-view-up-only-when-the-keyboard-covers-an-input-field/32555911#32555911 it might help – Mr H Aug 22 '16 at 02:48
  • @MrH, Thanks for the link :)... i've tried, but it's not working with `UITableview`. I've both `UIScrollView` and `UITableView` – arthankamal Aug 22 '16 at 14:39
  • please include code to get keyboard height in above question – Hitesh Surani Jan 17 '18 at 05:44
  • Use TPKeyboardManager. It works for both table view and scroll view. – AAA Jan 23 '18 at 11:27
  • 1
    Hm for custom keyboards the UIKeyboardFrameEndUserInfoKey should work.. Are you sure when you use UIKeyboardDidShowNotification and UIKeyboardFrameEndUserInfoKey it's still wrong? Perhaps this link might help as well: https://stackoverflow.com/questions/15402281/convert-uikeyboardframeenduserinfokey-to-view-or-window-coordinates – Bob de Graaf Jan 23 '18 at 12:14
  • Also had this problem with RxKeyboard and Gboard, somewhat fixed it by using keyboard `frame` and not `willShowVisibleHeight` driver. – Cfr Mar 04 '19 at 09:29

1 Answers1

2

Its late, but UIKeyboardWillChangeFrameNotification is what U want.

Jack Martin
  • 129
  • 10