iPad分体键盘 [英] iPad split-keyboard

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

问题描述

我正在创建一个类似于iPad的iMessage应用程序的应用程序,用于发送消息。因此,当显示键盘时,有一个输入视图锚定在消息视图的底部并输入附件视图。在停靠或取消停靠时显示键盘时,必须正确调整消息视图的大小。

I am creating an app similar to the iPad's iMessage app that does messaging. So there is an input view anchored at the bottom of the message view and input accessory view when the keyboard is shown. Also the message view must be resized properly when the keyboard is shown while docked or undocked.

我遇到的问题是来自UIKeyboardWillChangeFrameNotification的通知数据不一致。

The problem I have is that the notification data that comes in from UIKeyboardWillChangeFrameNotification is not consistent.

首先,用户可以通过3种方式取消键盘:

First, there are 3 ways that the user can undock the keyboard:


  1. 按住右下方的键,然后向上滑动

  2. 按住右下方的键,弹出菜单时选择取消停靠

  3. 按住右下方的按键,弹出菜单后选择拆分

对于案例#1,来自UIKeyboardWillChangeFrameNotification的通知数据是一致的。以下是数据:

For case #1, the notification data from UIKeyboardWillChangeFrameNotification is consistent. Here is the data:

userInfo = {
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
}

对于案例#2和#3,数据不一致,这是我的意思收到:

For case #2 and #3 the data is inconsistent, here is what I receive:

userInfo = {
    UIKeyboardAnimationCurveUserInfoKey = 0;
    UIKeyboardAnimationDurationUserInfoKey = "0.25";
    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {384, 872}";
    UIKeyboardCenterEndUserInfoKey = "NSPoint: {384, 1136}";
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
    UIKeyboardFrameChangedByUserInteraction = 0;
    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, -264}, {768, 304}}";
}

这里奇怪的是,当我在案例#2下听取UIKeyboardDidChangeFrameNotification或#3,数据按预期进入:

What is odd here is that when I listen for UIKeyboardDidChangeFrameNotification under case #2 or #3, the data comes in as expected:

userInfo = {
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
}

为什么通知数据不同?有没有人找到一种清晰的方法来检测分裂键盘事件?

Why is the notification data different? Did anybody find a clear way to detect the split-keyboard events?

推荐答案

没有明确的方法没有。

我将在接下来的步骤中解决此问题:

i resolve this trouble in next steps:


  1. 获取当前方向。

  2. 如果orientation是Landscape,那么我得到UIKeyboardFrameEndUserInfoKey的 height 。它必须等于216.这意味着键盘是分离模式,否则不是;

  3. 如果orientation是Portrait,那么我得到UIKeyboardFrameEndUserInfoKey的 height 。它必须等于216.这意味着键盘是分离模式,否则不是;

  1. Get current orientation.
  2. If orientation is Landscape then i get height of UIKeyboardFrameEndUserInfoKey. it must equals to 216. It means keyboard is Split mode, Else not;
  3. If orientation is Portrait then i get height of UIKeyboardFrameEndUserInfoKey. it must equals to 216. It means keyboard is Split mode, Else not;

我更新了我的 gist例如。使用convertRect方法。

I update my gist for example. With convertRect method.

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

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