gpt4 book ai didi

ios - becomeFirstResponder 重置其他 View 的 x/y 位置

转载 作者:搜寻专家 更新时间:2023-11-01 05:41:46 25 4
gpt4 key购买 nike

我在两个 UITextFields 上做一些动画。当一个文本字段完成编辑后,我使用 UIView.animateWithDuration 将第一个文本字段设置为左侧动画,然后调用 UIView.animateWithDuration 显示第二个文本编辑字段。

问题是,当我在第二个文本字段上调用 ​​becomeFirstResponder() 时,它会恢复第一个 ui 文本字段上的新 x/y 坐标。

这是怎么回事?

编辑

代码提供

func animateMe() {
UIView.animateWithDuration(0.5, delay: 0, options: .CurveEaseOut, animations: {
self.onText.frame.offset(dx: self.onText.frame.size.width / -4 * 3 - 10, dy: 0)
}, completion: { finished in
println("one shown!")
self.oneText.frame.offset(dx: self.onText.frame.size.width / -4 * 3 - 10, dy: 0)
self.twoText.becomeFirstResponder() //undoes the whole animation
})
}

最佳答案

在 UIView 动画方法的完成 block 中,将 UITextfield 的框架设置到目标新位置。动画不会为您做那件事,这是违反直觉的,但解释太长了。

关于ios - becomeFirstResponder 重置其他 View 的 x/y 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28819620/

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