gpt4 book ai didi

ios - 自定义键盘关闭按钮效果很好,直到焦点转移到另一个文本字段

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

这是我的 View ,显示自定义键盘关闭按钮。看看它看起来多漂亮?效果也很好,直到您点击其他两个文本输入字段之一...然后关闭按钮跳回到我在 GUI 设计器中创建它时最初放置的位置。请注意,在点击第二个字段后的第二个屏幕截图中,您可以隐约看到关闭按钮的位置完全被半透明的键盘隐藏。

在这里,用户最初点击 3 个文本输入字段中的任何一个后,一切都很好......

enter image description here

这是当用户点击其他 2 个文本字段中的任何一个时它会执行的操作...关闭按钮在界面中向下跳回并隐藏在键盘后面...

enter image description here

为什么按钮会跳回设计工具中指定的 xcode-designer-location?当用户点击不同的字段时,我不明白是什么让按钮重置位置。

这是执行过程中任何时候唯一正在运行的代码。我首先捕获键盘通知...

- (void)keyboardWillShow:(NSNotification *)notification
{

UIButton *but;
but = (UIButton *)[self.view viewWithTag:4400];

if ([but isHidden])
[but setHidden:NO];

// Get animation info from userInfo
NSTimeInterval animationDuration;
UIViewAnimationCurve animationCurve;
NSDictionary* userInfo = [notification userInfo];

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

// get the custom dismissal button's frame so we can move it
CGRect newFrame = but.frame;
newFrame.origin.y = [[UIScreen mainScreen ] bounds ].size.height - keyboardEndFrame.size.height;
but.frame = newFrame;

[UIView commitAnimations];
}

最佳答案

这与您的问题正交,但是让 View 自动出现在键盘上方的正确方法是将其设置为您需要的任何文本字段的 inputAccessoryView。这样您就无需担心键盘框架。

我不确定您的具体情况是什么问题,但我认为当您从一个文本字段移动到下一个文本字段时,会立即调用 willHide/willShow 方法,并且您假设动画将是发生。

当用户隐藏或显示键盘上方的自动完成栏时,您当前的方法也会遇到问题。输入附件 View 是要走的路。

关于ios - 自定义键盘关闭按钮效果很好,直到焦点转移到另一个文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27628859/

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