Moving a textfield with auto layout constraints when the keyboard appears

后端 未结 1 1123
一个人的身影
一个人的身影 2020-12-12 06:17

I have a search bar text field and a table view (for google auto complete) that I would like to translate up when the keyboard comes into view. I am successfully doing this,

相关标签:
1条回答
  • 2020-12-12 06:31

    Instead of adjusting theframe values, I think you should be creating @IBOutlet references to constraints in Interface Builder and then changing the constant value of those constraints when you want to animate them, followed by a call to layoutIfNeeded. As I understand it, manually changing the values of a view's frame and auto layout don't mix.

    Also, I wouldn't mess around with setTranslatesAutoresizingMaskIntoConstraints unless you are adding your constraints programmatically, in which case you're most likely just setting it to false.

    0 讨论(0)
提交回复
热议问题