2

This is a problem that occurs when experimenting with iPhone X.

I'm get keyboard size from this way.

let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue
print(keyboardSize)

This is the first time the keyboard is up after running the app.

(keyboardSize = (0.0, 812.0, 375.0, 291.0)

However, once it disappears and then reappears, it always prints as follows.

(keyboardSize = (0.0, 812.0, 375.0, 233.0)

The numbers vary, but the actual keyboard size is the same. Why does that code have different height values?

1 Answers1

3

Using UIKeyboardFrameEndUserInfoKey instead of UIKeyboardFrameBeginUserInfoKey should be the answer

CZ54
  • 5,488
  • 1
  • 24
  • 39