UIKeyboardFrameBeginUserInfoKey& UIKeyboardFrameEndUserInfoKey [英] UIKeyboardFrameBeginUserInfoKey & UIKeyboardFrameEndUserInfoKey

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

问题描述

在管理键盘中文档


UIKeyboardFrameBeginUserInfoKey 包含
CGRect的NSValue对象的
键在屏幕坐标中标识键盘的起始帧

这些坐标不会占用
帐户任何旋转因子应用
到窗口的内容,因此
的界面方向发生变化。
因此,您可能需要将
矩形转换为窗口坐标(使用
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 包含$ b $的NSValue对象的键
b 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 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.

还要确保使用 UIKeyboardAnimationCurveUserInfoKey UIKeyboardAnimationDurationUserInfoKey 当动画视图发生变化时:这样,您的动画和操作系统的动画将同步。

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上,情况并非如此。两个rects具有相同的大小,而屏幕坐标中的原点在两者之间有所不同。

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,而是使用什么?

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

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

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