iOS:获取正确的ThirdPart键盘高度 [英] iOS: Get correct height of thirdPart keyboard

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

问题描述

自从iOS8起,出现了许多ThirdPart键盘显示,我想在显示时获得键盘高度

Since iOS8, many thirdPart keyboard shows, i want to get the keyboard height when it show

NSDictionary* info = [aNotification userInfo]; CGSize kbSize = 
[[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

但是我可以获取系统键盘的高度,但是却不能获取ThirdKey键盘(例如SouGouKeyboard),它返回0而不是如何获取正确的高度?

however i can get the height of system keyboard, but can't get a thirdPart keybord(such as SouGouKeyboard),it return 0 instead how to get the correct height?

它返回: { UIKeyboardAnimationCurveUserInfoKey = 7; UIKeyboardAnimationDurationUserInfoKey = "0.25"; UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 0}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 568}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 568}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 568}, {320, 0}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 568}, {320, 0}}"; }

it returns : { UIKeyboardAnimationCurveUserInfoKey = 7; UIKeyboardAnimationDurationUserInfoKey = "0.25"; UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 0}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 568}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 568}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 568}, {320, 0}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 568}, {320, 0}}"; }

推荐答案

您可以尝试此方法

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

 - (void)keyboardWasShown:(NSNotification *)notification
{
  CGSize keyboardSize = [[[notification userInfo]objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
  int height = MIN(keyboardSize.height,keyboardSize.width);
  int width = MAX(keyboardSize.height,keyboardSize.width);
}

这篇关于iOS:获取正确的ThirdPart键盘高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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