iOS 5 中未连接的键盘不会调用 UIKeyboardWillShowNotification
我发现当 iOS 5
中出现未固定/拆分键盘时,不会生成 UIKeyboardWillShowNotification
和 UIKeyboardDidShowNotification
。例如,点击文本字段以显示键盘(生成通知),取消固定键盘,点击文本字段以关闭键盘,再次点击文本字段以显示取消固定的键盘(通知为 未生成)。
有没有什么方法可以检测键盘何时出现,无论键盘是否插入底座?
I have found that UIKeyboardWillShowNotification
and UIKeyboardDidShowNotification
are not generated when an undocked/split keyboard appears in iOS 5
. For instance, tap into a text field to show the keyboard (notifications are generated), undock the keyboard, tap out of the text field to dismiss the keyboard, tap on the text field again to show the undocked keyboard (notifications are not generated).
Is there any way to detect when the keyboard appears regardless of whether it is docked or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要改为观察
UIKeyboardWillChangeFrameNotification
和UIKeyboardDidChangeFrameNotification
。获得它们后,您可以查看UIKeyboardFrameEndUserInfoKey
的值(如果存在,则在拖动键盘时并不总是存在)并查看该矩形是否与窗口相交,以查看键盘现在是否存在在屏幕上或屏幕外。You need to observe
UIKeyboardWillChangeFrameNotification
andUIKeyboardDidChangeFrameNotification
instead. When you get them, you can look at the value forUIKeyboardFrameEndUserInfoKey
(if it exists, it doesn't always while dragging the keyboard) and see if that rect intersects the window to see if the keyboard is now on or off screen.如果键盘显示为未连接/分离,您不需要检测它。分离式/分离式键盘的全部要点是,如果它妨碍了用户,用户可以自由移动它。
If the keyboard appears undocked / split, you don't need to detect it. The whole point of the undocked / split keyboard is that the user can move it freely if it's in the way.