在 iOS 5 中未调用 UIKeyboardWillShowNotification [英] UIKeyboardWillShowNotification not called for an undocked keyboard in iOS 5

查看:23
本文介绍了在 iOS 5 中未调用 UIKeyboardWillShowNotification的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现 iOS 5 中出现非停靠/拆分键盘时不会生成 UIKeyboardWillShowNotificationUIKeyboardDidShowNotification.例如,点击文本字段以显示键盘(生成通知),取消停靠键盘,点击文本字段以关闭键盘,再次点击文本字段以显示取消停靠的键盘(通知是 没有生成).

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?

推荐答案

你需要观察UIKeyboardWillChangeFrameNotificationUIKeyboardDidChangeFrameNotification.当你得到它们时,你可以查看 UIKeyboardFrameEndUserInfoKey 的值(如果它存在,它并不总是在拖动键盘时)并查看该矩形是否与窗口相交以查看键盘是否现在在屏幕上或屏幕外.

You need to observe UIKeyboardWillChangeFrameNotification and UIKeyboardDidChangeFrameNotification instead. When you get them, you can look at the value for UIKeyboardFrameEndUserInfoKey (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.

这篇关于在 iOS 5 中未调用 UIKeyboardWillShowNotification的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆