iPad 键盘尺寸
我在苹果文档中找到了iPhone的键盘界限,但找不到iPad的键盘界限。请你帮助我好吗?
I have found the iPhone's keyboard bounds in the apple documentation, but I can't find the iPad's keyboard bounds. Could you please help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
代码中的整个答案如下所示。首先,您需要注册通知:
还有更多这里< /a>.请注意,您还需要删除它们(使用
removeObserver
)。然后你需要一个方法来获取通知以获取大小。请注意,尺寸一开始并未旋转(因为
UIWindow
不会旋转。它的内容会旋转)。显然,如果您通过其他方式引用了
mainSubviewOfWindow
,请使用它。The entire answer in code looks like this. First you need to register for the notifications:
and there are more here. Note that you'll need to get rid of them, too (use
removeObserver
).Then you need a method that gets the notification to get the size. Note that the size is, at first, not rotated (since the
UIWindow
doesn't rotate. Its contents do).Obviously, if you have a reference to your
mainSubviewOfWindow
by some other means, use it.iPhone 的纵向为 216 像素,横向为 162 像素,iPad 的纵向为 264 像素,横向为 352 像素。这对于 2010 年的美国键盘有效。
这些大小对于其他语言可能有所不同,并且对于美国也可能会发生变化。
For iPhone in portrait 216 pixels, landscape 162 pixels, for iPad in portrait it's 264 pixels and in landscape 352 pixels. This is valid for US keyboard in 2010.
These sizes can be different for other languages, and might change for US as well.
请注意,如果用户选择在 iPad 上使用“拆分”键盘,则不会触发 UIKeyboardDidShowNotification/*UIKeyboardDidHideNotification* 通知。相反,UIKeyboardDidChangeFrameNotification 通知将在显示和隐藏时触发。您必须分析 keyboardFrame.origin.y 才能弄清楚到底发生了什么(显示或隐藏)。
Please note that if user choose to use "split" keyboard on iPad, then UIKeyboardDidShowNotification/*UIKeyboardDidHideNotification* notifications will not be fired. Instead, UIKeyboardDidChangeFrameNotification notification will be fired on both show and hide. You will have to analyze keyboardFrame.origin.y to figure out what exactly happen (show or hide).
如果其他人需要它,我刚刚找到它。
键盘通知用户信息键
I just found it if somebody else needs it.
Keyboard Notification User Info Keys