UIKeyboard iOS 8通知的建议高度? [英] UIKeyboard Suggestions height for iOS 8 notification?

查看:53
本文介绍了UIKeyboard iOS 8通知的建议高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在iOS 8的键盘上方保留一个文本字段,但是当用户向上或向下滑动键盘顶部以显示或关闭iOS 8单词建议时,我需要通知新键盘的高度,这样我就可以将文本字段上下移动该高度.

I'm trying to keep a text field sitting atop the keyboard in iOS 8. But when a user swipes up or down the top of the keyboard to show or dismiss iOS 8 word suggestions, I need to a notification of the new height of the keyboard so I can move my text field up or down by that height.

我该怎么做?

谢谢!

推荐答案

您可以注册UIKeyboardDidShowNotification,然后使用UIKeyboardFrameEndUserInfoKey从通知中获取键盘框架.

You can register for UIKeyboardDidShowNotification and then get the keyboard frame from the notification with UIKeyboardFrameEndUserInfoKey.

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(handleKeyboardDidShowNotification:) 
                                             name:UIKeyboardDidShowNotification 
                                           object:nil];


- (void)handleKeyboardDidShowNotification:(NSNotification *)notification
{
    NSDictionary* info = [notification userInfo];
    CGSize keyboardSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
    // Move your textview into view here
}

即使在键盘已经显示并且即将改变大小的情况下,也会发送此通知,因此,只要在键盘顶部向上或向下滑动,便会收到该通知.

This notification will be sent even in the event that the keyboard is already showing and is just going to change size, so you'll get it whenever you swipe up or down on the top of the keyboard.

这篇关于UIKeyboard iOS 8通知的建议高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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