获取表情键盘IOS 8的高度

获取表情键盘IOS 8的高度,ios,objective-c,uikeyboard,Ios,Objective C,Uikeyboard,键盘信息字典返回的表情符号键盘高度数字不正确。如果我点击文本字段,它会将普通键盘设置为动画,但当我点击表情符号时,它仍然认为高度是标准键盘。为什么?有没有办法通过编程获得备用(表情符号)键盘高度。常数37是一个可怕的黑客,我把它的工作 - (void)keyboardWillShow:(NSNotification *)notification { if (!IS_SHOWING_KEYBOARD) { IS_SHOWING_KEYBOARD=YES;

键盘信息字典返回的表情符号键盘高度数字不正确。如果我点击文本字段,它会将普通键盘设置为动画,但当我点击表情符号时,它仍然认为高度是标准键盘。为什么?有没有办法通过编程获得备用(表情符号)键盘高度。常数37是一个可怕的黑客,我把它的工作

- (void)keyboardWillShow:(NSNotification *)notification {
    if (!IS_SHOWING_KEYBOARD)   {
        IS_SHOWING_KEYBOARD=YES;

        NSDictionary *userInfo = [notification userInfo];
        CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
        keyboardSize = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

        [self.view layoutIfNeeded];
        self.commentTopLayout.constant -= keyboardSize.height;
        self.commentBottomLayout.constant -= keyboardSize.height;
        [UIView animateWithDuration:0.2f animations:^{
            [self.view layoutIfNeeded];
        }];

    } else { //move him down, then up again. //clicked on emojis
        NSDictionary *userInfo = [notification userInfo];
        CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
        keyboardSize = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

        [self.view layoutIfNeeded];
        self.commentTopLayout.constant += keyboardSize.height;
        self.commentBottomLayout.constant += keyboardSize.height;
        [UIView animateWithDuration:0.2f animations:^{
            [self.view layoutIfNeeded];
        }];



        [self.view layoutIfNeeded];
        self.commentTopLayout.constant -= keyboardSize.height+37;
        self.commentBottomLayout.constant -= keyboardSize.height+37;

        [UIView animateWithDuration:0.2f animations:^{
            [self.view layoutIfNeeded];
        }];



    }

}

我也有同样的问题。只需将
UIKeyboardFrameBeginUserInfoKey
替换为
UIKeyboardFrameEndUserInfoKey
:-)

可能重复@Dejan Skledar我正在使用与他们相同的解决方案,据我所知,它不起作用。