gpt4 book ai didi

ios - UIKeyboardBoundsUserInfoKey 已弃用,改用什么?

转载 作者:IT老高 更新时间:2023-10-28 11:35:14 25 4
gpt4 key购买 nike

我正在使用 3.2 sdk 开发 iPad 应用程序。我正在处理获取键盘大小以防止我的文本字段隐藏在它后面。

我在 Xcode 中收到警告 -> UIKeyboardBoundsUserInfoKey 已弃用我应该使用什么来代替收到此警告?

最佳答案

我使用了之前提供的解决方案,但仍有问题。这是我想出的:

    - (void)keyboardWillShow:(NSNotification *)aNotification {
[self moveTextViewForKeyboard:aNotification up:YES];
}

- (void)keyboardWillHide:(NSNotification *)aNotification {
[self moveTextViewForKeyboard:aNotification up:NO];
}

- (void) moveTextViewForKeyboard:(NSNotification*)aNotification up: (BOOL) up{
NSDictionary* userInfo = [aNotification userInfo];

// Get animation info from userInfo
NSTimeInterval animationDuration;
UIViewAnimationCurve animationCurve;

CGRect keyboardEndFrame;

[[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&animationCurve];
[[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&animationDuration];


[[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardEndFrame];


// Animate up or down
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:animationDuration];
[UIView setAnimationCurve:animationCurve];

CGRect newFrame = textView.frame;
CGRect keyboardFrame = [self.view convertRect:keyboardEndFrame toView:nil];

newFrame.origin.y -= keyboardFrame.size.height * (up? 1 : -1);
textView.frame = newFrame;

[UIView commitAnimations];
}

关于ios - UIKeyboardBoundsUserInfoKey 已弃用,改用什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2807339/

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