I have the following code which worked on IOS 10, but now it doesn't work anymore when running on IOS 11 beta.
if let userInfo = notification.userInfo {
if let keyboardSize = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
print(keyboardSize)
}
}
This is what I get when I print the size:
(0.0, 0.0, 0.0, 0.0)
(0.0, 736.0, 414.0, 0.0)
Anyone knows why this has stopped working ? Or if I have any other alternatives to get the keyboard size ?
Use UIKeyboardFrameEndUserInfoKey
instead of UIKeyboardFrameBeginUserInfoKey
So changing your code to the following will fix your issue:
if let userInfo = notification.userInfo {
if let keyboardSize = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
print(keyboardSize)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With