在iOS8中无法获得键盘高度的正确值 [英] can't get correct value of keyboard height in iOS8

查看:366
本文介绍了在iOS8中无法获得键盘高度的正确值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这段代码来决定键盘的大小:

   - (void)keyboardWillChange:(NSNotification *)notification {
NSDictionary * keyboardInfo = [notification userInfo];
NSValue * keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameBeginUserInfoKey];
CGRect keyboardFrameBeginRect = [keyboardFrameBegin CGRectValue];

}

我在模拟器中运行。 >

问题是从iOS 8这将不会给出正确的值,如果键盘建议是向上或如果我推下他们得到不同的(不正确的)值。



如何获得键盘的确切大小,包括键盘建议?

解决方案

使用

  NSValue * keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameEndUserInfoKey]; 


I was using this code to determine what is the size of the keyboard :

- (void)keyboardWillChange:(NSNotification *)notification {
    NSDictionary* keyboardInfo = [notification userInfo];
    NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameBeginUserInfoKey];
    CGRect keyboardFrameBeginRect = [keyboardFrameBegin CGRectValue];

}

I'm running this in the simulator.

The problem is since iOS 8 this will not give the correct value, if the keyboard suggestions is up or if I push them down I get different (not correct) values.

How can I get the exact size of the keyboard including the keyboard suggestions?

解决方案

Use

NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameEndUserInfoKey];

这篇关于在iOS8中无法获得键盘高度的正确值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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