获得键盘高度不适用于IOS 11 beta [英] Get the height of keyboard doesn't work on IOS 11 beta
本文介绍了获得键盘高度不适用于IOS 11 beta的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码可用于IOS 10,但现在它在IOS 11测试版上运行时不再有效。
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 ?
推荐答案
使用 UIKeyboardFrameEndUserInfoKey
而不是 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)
}
}
这篇关于获得键盘高度不适用于IOS 11 beta的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文