簡體   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