UIKeyboardFrameBeginUserInfoKey &UIKeyboardFrameEndUs

UIKeyboardFrameBeginUserInfoKey amp; UIKeyboardFrameEndUserInfoKey(UIKeyboardFrameBeginUserInfoKey amp;UIKeyboardFrameEndUserInfoKey)

本文介绍了UIKeyboardFrameBeginUserInfoKey &UIKeyboardFrameEndUserInfoKey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在管理键盘文档:

UIKeyboardFrameBeginUserInfoKey包含一个 NSValue 对象的键标识起始帧的CGRect在屏幕坐标中的键盘.这些坐标不考虑考虑应用的任何旋转因子结果到窗口的内容界面方向的变化.因此,您可能需要将矩形到窗口坐标(使用convertRect:fromWindow: 方法)或查看坐标(使用convertRect:fromView: 方法)之前使用它.

UIKeyboardFrameBeginUserInfoKey The key for an NSValue object containing a CGRect that identifies the start frame of the keyboard in screen coordinates. These coordinates do not take into account any rotation factors applied to the window’s contents as a result of interface orientation changes. Thus, you may need to convert the rectangle to window coordinates (using the convertRect:fromWindow: method) or to view coordinates (using the convertRect:fromView: method) before using it.

UIKeyboardFrameEndUserInfoKey 关键对于包含一个 NSValue 对象标识结束帧的CGRect在屏幕坐标中的键盘.这些坐标不考虑考虑应用的任何旋转因子结果到窗口的内容界面方向的变化.因此,您可能需要将矩形到窗口坐标(使用convertRect:fromWindow: 方法)或查看坐标(使用convertRect:fromView: 方法)之前使用它.

UIKeyboardFrameEndUserInfoKey The key for an NSValue object containing a CGRect that identifies the end frame of the keyboard in screen coordinates. These coordinates do not take into account any rotation factors applied to the window’s contents as a result of interface orientation changes. Thus, you may need to convert the rectangle to window coordinates (using the convertRect:fromWindow: method) or to view coordinates (using the convertRect:fromView: method) before using it.

start frameend frame是什么意思?它们有什么区别?

What is the meaning of start frame and end frame? What is the difference between them?

推荐答案

起始帧是键盘在动画开始的位置:如果键盘正在显示,则在屏幕外,如果键盘正在隐藏,则在屏幕上.结束帧是动画结束时键盘所在的位置:反之亦然.您可以利用它们之间的差异编写一个方法来响应隐藏和显示键盘.

The start frame is where the keyboard is at the beginning of the animation: offscreen if the keyboard is being shown, or onscreen if the keyboard is being hidden. The end frame is where the keyboard will be at the end of the animation: vice versa. You can use the difference between them to write a single method that responds to both hiding and showing the keyboard.

确保在动画视图更改时也使用 UIKeyboardAnimationCurveUserInfoKeyUIKeyboardAnimationDurationUserInfoKey:这样,您的动画和操作系统的动画将同步.

Be sure also to use UIKeyboardAnimationCurveUserInfoKey and UIKeyboardAnimationDurationUserInfoKey when animating your view changes: that way, your animations and the OS's animations will be in sync.

另一个提示:您链接到的文档指出,userInfo 字典的 UIKeyboardFrameBeginUserInfoKey 和 UIKeyboardFrameEndUserInfoKey 属性中包含的矩形应仅用于其包含的大小信息.不要使用矩形的原点(始终{0.0, 0.0}) 在矩形相交运算中".至少在 OS 3.2 上的 iPad 上,这是不正确的.两个矩形的大小相同,而屏幕坐标中的原点在两者之间不同.

Another hint: The documentation you linked to states, "The rectangle contained in the UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey properties of the userInfo dictionary should be used only for the size information it contains. Do not use the origin of the rectangle (which is always {0.0, 0.0}) in rectangle-intersection operations". At least on the iPad on OS 3.2, this is not true. Both rects have the same size, while the origin, which is in screen coordinates, differs between the two.

您可能会发现这个问题很有帮助:UIKeyboardBoundsUserInfoKey is deprecated, what to use?

You may find this question helpful: UIKeyboardBoundsUserInfoKey is deprecated, what to use instead?

这篇关于UIKeyboardFrameBeginUserInfoKey &UIKeyboardFrameEndUserInfoKey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:UIKeyboardFrameBeginUserInfoKey &UIKeyboardFrameEndUs

基础教程推荐