2

I am using the code below:

CGRect keyboardFrame = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

but it doesn't work exactly.

mlg
  • 5,248
  • 1
  • 14
  • 17
tran minh
  • 21
  • 2
  • https://stackoverflow.com/questions/45689664/ios-11-keyboard-height-is-returning-0-in-keyboard-notification – iPatel Oct 16 '17 at 09:58
  • I'm using UIKeyboardFrameEndUserInfoKey but i want to continue getting the height when switching input type (means while keyboard is shown) – tran minh Oct 16 '17 at 10:03

2 Answers2

4

You can subscribe to notifications: UIKeyboardWillChangeFrame or UIKeyboardDidChangeFrame . In handlers you can get the end frame of the keyboard.
Here I’ve created an example application.

Andrew Romanov
  • 4,774
  • 3
  • 25
  • 40
  • when switching keyboard type from ASCII to emoji, it does not send UIKeyboardWillChangeFrame/UIKeyboardDidChangeFrame notification. – tran minh Oct 17 '17 at 06:38
  • If a keyboard frame really will change, notification will send. You can exam it in a my example application: https://github.com/K-Be/KeyboardNotifications . (Rotate a device to landscape and switch to Emoji) – Andrew Romanov Oct 17 '17 at 09:07
  • Thank you! but did you try to switch keyboard input type to emoji when keyboard is displayed? – tran minh Nov 02 '17 at 07:13
  • Yes I did. You can download my example and see it. – Andrew Romanov Nov 02 '17 at 07:46
  • I have test, UIKeyboardWillChangeFrameNotification won't be called when input change to emoji – PatrickSCLin Nov 29 '17 at 07:16
  • A reason to post the notification is a changing of a frame of a input view. If a phone in a portrait orientation with a hints panel, frame will not change. – Andrew Romanov Nov 29 '17 at 07:24
2

When switching to emoji keyboard by pressing the language selector button (the globe), it seems that a UIKeyboardWillChangeFrame-notification gets sent. But when changing by long pressing the language selector button, no notification is sent.

It looks to me as a bug in iOS 11, since even the apple messages app and facebook messenger app doesn't handle this right. I've submitted a radar about this with id: 36657137

Wiingaard
  • 4,150
  • 4
  • 35
  • 67