繁体   English   中英

出现键盘时,它会重置内部视图的偏移量

[英]When keyboard appears it resets offset of inside views

通过点击按钮,我将所有内容向上移动,并在我要移动的一个UIViews中显示UITextField:

UIView.animateWithDuration(0.7, delay: 0.0, options: .CurveEaseOut, animations: {
      self.logo.frame.offset(dx: 0, dy: -200)
}, completion: nil)
UIView.animateWithDuration(0.2, delay: 0.1, options: .CurveEaseOut, animations: {
      self.fill.frame.offset(dx: 0, dy: -230)
}, completion: nil)
UIView.animateWithDuration(0.3, delay: 0.5, options: .CurveEaseOut, animations: {
      self.form.frame.offset(dx: 0, dy: -240)
      self.form.alpha = 1.0
}, completion: nil)

但是,当我点击UITextfield(以UIView的形式)并出现键盘时,它将重置所有内容的偏移量。

如何避免呢?

我猜您正在使用自动版式将项目放置在视图内,该视图想修复框架“错位”。 添加具有约束的UITextField并更改内容约束中的值。

同样,当您使用tableview.rowHeight = UITableViewAutomaticDimension ,行会自动适应新的高度。

除了动画,您不应将frame用于任何其他东西,动画的结果已经是AutoLayout所期望的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM