gpt4 book ai didi

iOS8 KeyboardWillShowNotification 第三方键盘高度

转载 作者:可可西里 更新时间:2023-11-01 03:28:44 32 4
gpt4 key购买 nike

<分区>

我的 UI 在显示键盘时需要进行一些位置调整。

以下用于检测何时显示键盘:

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];

注意:我已经尝试过 UIKeyboardWillShowNotification 和 UIKeyboardDidShowNotification

- (void)keyboardWillShow:(NSNotification *)n {
if (isKeyboardShowing)
return;

NSDictionary* userInfo = [n userInfo];

// get the size of the keyboard
CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;


// Animate keyboard shift
[self.view layoutIfNeeded];

[UIView animateWithDuration:0.2f animations:^{
// some animation here
} completion:^(BOOL finished) {
if (finished)
isKeyboardShowing = YES;
}];

对于自定义键盘,键盘大小返回 {320, 0}。由于键盘现在可以有不同的高度,因此我无法在出现键盘时使用静态值来更改 UI。

这是 ios8 的问题吗?还有其他动态获取键盘高度的方法吗?

编辑:这是 userInfo Dict:

{name = UIKeyboardDidShowNotification; userInfo = {
UIKeyboardAnimationCurveUserInfoKey = 7;
UIKeyboardAnimationDurationUserInfoKey = "0.25";
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 0}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 568}, {320, 0}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 568}, {320, 0}}";
}}

提前致谢。

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