I have a following view hierarchy Main -> Green -> Img
The Green view has the constraints seen in image below
The Img view has the constraints seen in the image below
So when I click the Button the frame of the Green is resized, and so the Img view because of the constraints between them.
But I get an error:
2015-06-07 20:13:07.653 ZoomInZoomOut[7152:1435937] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "", "", " (Names: '|':UIWindow:0x7fcbd3623630 )>", "" )
Will attempt to recover by breaking constraint
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. 2015-06-07 20:13:07.655 ZoomInZoomOut[7152:1435937] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "", "<_UILayoutSupportConstraint:0x7fcbd347fb60 V:[_UILayoutGuide:0x7fcbd3487f80(20)]>", "<_UILayoutSupportConstraint:0x7fcbd347e3f0 V:|-(0)-[_UILayoutGuide:0x7fcbd3487f80] (Names: '|':UIView:0x7fcbd3480a20 )>", "<_UILayoutSupportConstraint:0x7fcbd347dd20 V:[_UILayoutGuide:0x7fcbd34889a0(0)]>", "<_UILayoutSupportConstraint:0x7fcbd3481700 _UILayoutGuide:0x7fcbd34889a0.bottom == UIView:0x7fcbd3480a20.bottom>", "", " (Names: '|':UIWindow:0x7fcbd3623630 )>", "" )
Will attempt to recover by breaking constraint
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.
The code called when the button is clicked:
@IBAction func buttonClicked(sender: UIButton) {
zoomedView.frame.size.height += 10.0
zoomedView.frame.size.width += 10.0
zoomedView.setTranslatesAutoresizingMaskIntoConstraints(true)
zoomedView.superview?.updateConstraints()
}
From Auto Layout Tutorial Part 2: Constraints I know that this error is caused by conflicting constraints. But I didn't add any new constraints in code behind. In storyboard if I resize the Green view, I get a misplaced view which I fix by updating constraints. That is why I'm trying to achieve in code behind, but get the error from above. Could anyone explain what I'm doing wrong?