I am simply using
toolBar.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0).isActive = true
for setting up my topAnchor.
However, when I change the constant from 0 to an actual number, the console gives me
[LayoutConstraints] Unable to simultaneously satisfy constraints.
this error. I am calling this constraint in viewDidLoad
but changing it to viewWillLayoutSubviews
or other parts do not solve the problem.
How do I fix this error? Thank you!
Because you create another one , you need to edit the current one
var topCon:NSLayoutConstraint!
topcon = toolBar.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0)
topCon.isActive = true
Then play with constant
topCon.constant = // anyNumber
我只需要把 translatesAutoresizingMaskIntoConstraints = false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.