键盘信息字典返回不正确的表情符号键盘高度数字。如果我单击文本字段,它会很好地激活普通键盘,但是当我单击表情符号时,它仍然认为高度是标准键盘。为什么?有没有办法以编程方式获取备用(表情符号)键盘高度。常量 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
即可。 :-)
关于ios - 获取表情符号键盘IOS 8的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30059514/