I am making a custom keyboard and I have a function named setButtonConstraints(). When I insert this function into the viewDidLoad() and run my app the constraints are properly set. However when I move the function call into the override func updateViewConstraints() (which is supposed to be called after the subviews have been layed out) no constraints are set. What is the cause of this?
This is what the simple updateViewConstraints() looks like:
override func updateViewConstraints() {
super.updateViewConstraints()
// Add custom view sizing constraints here
setButtonConstraints()
}
Per Apple's documentation, updateViewConstraints()
only gets called if the constraints need to be updated. Also, I believe you need to call the super.updateViewConstraints()
after you change constraints.
The following link is helpful.
Where should I be setting autolayout constraints when creating views programmatically