smith938584
smith938584

Reputation: 51

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.

- (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];
        }];



    }

}

Upvotes: 1

Views: 860

Answers (1)

Ankush
Ankush

Reputation: 2555

I had the same problem. Just replace UIKeyboardFrameBeginUserInfoKey with UIKeyboardFrameEndUserInfoKey . :-)

Upvotes: 2

Related Questions