2

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!

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

5 Comments

this does not fix the problem I still get [LayoutConstraints] Unable to simultaneously satisfy constraints.
please post all context
"<NSAutoresizingMaskLayoutConstraint:0x600002ed0ff0 h=-&- v=--& Material.Toolbar:0x7fa723e09140'\Uc11c\Uc6b8 \Ubc84\Uc2a4 \Uc54c\Ub78c \Uc124\Uc815'.midX == UIView:0x7fa723f0f8d0.midX - 207 (active)>", "<NSAutoresizingMaskLayoutConstraint:0x600002ed1180 h=-&- v=--& Material.Toolbar:0x7fa723e09140'\Uc11c\Uc6b8 \Ubc84\Uc2a4 \Uc54c\Ub78c \Uc124\Uc815'.width == UIView:0x7fa723f0f8d0.width - 414 (active)>", "<NSLayoutConstraint:0x600002ed0730 H:|-(50)-[Material.Toolbar:0x7fa723e09140'\Uc11c\Uc6b8 \Ubc84\Uc2a4 \Uc54c\Ub78c \Uc124\Uc815'] (active, names: '|':UIView:0x7fa723f0f8d0 )>"
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x600002ed0730 H:|-(50)-[Material.Toolbar:0x7fa723e09140'서울 버스 알람 설정'] (active, names: '|':UIView:0x7fa723f0f8d0 )>
the conflict between centerX , width , post the constraints
0

I Simply needed to put translatesAutoresizingMaskIntoConstraints = false

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.