gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 10:30:08 25 4
gpt4 key购买 nike

键盘信息字典返回不正确的表情符号键盘高度数字。如果我单击文本字段,它会很好地激活普通键盘,但是当我单击表情符号时,它仍然认为高度是标准键盘。为什么?有没有办法以编程方式获取备用(表情符号)键盘高度。常量 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com