我正在创建一个类似于 iPad s iMessage 应用程序的应用程序, 用于发送消息。 因此在显示键盘时, 在信件视图的底部有一个输入视图, 以及输入辅助视图。 当键盘在对接或撤消时显示键盘时, 也必须对信件视图进行适当调整大小 。
我的问题是,来自UIKeyboard WillChangeFrame通知的通知数据不一致。
首先,有三种方法用户可以取消键盘:
- Press-and-hold the lower right key, then slide up
- Press-and-hold the lower right key, when the menu pops up, select "undock"
- Press-and-hold the lower right key, when the menu pops up, select "split"
对于第1个案例,来自UIKeyboard WillC changeFrame通知的通知数据是一致的。以下是数据:
userInfo = {
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
}
对于第2和第3个案例,数据不一致, 这是我收到的:
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}}";
}
奇怪的是当我听到UIKeyboard DidedC changeFrame通知第2或第3号案件,
userInfo = {
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {768, 304}}";
}
通知数据为何不同?有没有人找到清晰的方法来检测断键器事件?