简体   繁体   English

获取表情符号键盘IOS 8的高度

[英]Getting height of Emoji keyboard IOS 8

The keyboard info dictionary is returning incorrect numbers for the emoji keyboard height. 键盘信息字典返回的表情符号键盘高度数字不正确。 If I click on the textfield it animates up the normal keyboard fine but when i click on the emoji's it still thinks the height is the standard keyboard. 如果我在文本字段上单击,它将使正常的键盘动画效果很好,但是当我单击表情符号时,它仍然认为高度是标准键盘。 Why? 为什么? And is there a way to get the alternate (emoji) keyboard height programatically. 并且有一种方法可以通过编程获取备用(表情符号)键盘高度。 The constant 37 is a terrible hack that I put in to get it to work. 常数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];
        }];



    }

}

I had the same problem. 我有同样的问题。 Just replace UIKeyboardFrameBeginUserInfoKey with UIKeyboardFrameEndUserInfoKey . 只需将UIKeyboardFrameBeginUserInfoKey替换为UIKeyboardFrameBeginUserInfoKey UIKeyboardFrameEndUserInfoKey :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM