Skip to content

Instantly share code, notes, and snippets.

@kongtomorrow
Created September 21, 2014 18:32
Show Gist options
  • Save kongtomorrow/d740914b96bc30e19402 to your computer and use it in GitHub Desktop.
Save kongtomorrow/d740914b96bc30e19402 to your computer and use it in GitHub Desktop.
2014-09-21 11:21:04.807 ALtest[42953:7217373] 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)
/// As it says, we need to read the constraints one by one and see if there's one that says something we don't want.
(
"<NSLayoutConstraint:0x7f9e39f344f0 H:[UIButton:0x7f9e39f339d0'1'(20)]>",
/// first button is width 20 – ***I bet you didn't want this and it needs to be deleted***
"<NSLayoutConstraint:0x7f9e39f37440 UIButton:0x7f9e39f339d0'1'.leading == UIView:0x7f9e39f336c0.leadingMargin + 65>",
/// |-65-[button1]
"<NSLayoutConstraint:0x7f9e39f37490 UIButton:0x7f9e39f35e30'2'.width == UIButton:0x7f9e39f339d0'1'.width>",
/// button1 and button2 same width (so 20)
"<NSLayoutConstraint:0x7f9e39f37530 H:[UIButton:0x7f9e39f339d0'1']-(65)-[UIButton:0x7f9e39f35e30'2']>",
/// 65 space btw bt1 and bt2
"<NSLayoutConstraint:0x7f9e39f375d0 H:[UIButton:0x7f9e39f35e30'2']-(65)-[UIButton:0x7f9e39f35770'3']>",
/// 65 space btw bt2 and bt3
"<NSLayoutConstraint:0x7f9e39f376c0 UIButton:0x7f9e39f35770'3'.width == UIButton:0x7f9e39f339d0'1'.width>",
/// button1 and button3 same width (so 20)
"<NSLayoutConstraint:0x7f9e39f37710 UIView:0x7f9e39f336c0.trailingMargin == UIButton:0x7f9e39f35770'3'.trailing + 65>",
/// [button3]-65-|
"<NSLayoutConstraint:0x7f9e39f3d220 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f9e39f336c0(375)]>"
/// superview needs to be 375 points wide
)
The problem is that every button is constrained to be width 20 and every space is constrained to be 65. Nothing can flex at all.
So it has to be 65+20+65+20+65+20+65 == 320 points wide. That's no good, because the superview has to be 375 points wide.
If you wanted the width of the buttons to get bigger as the screen gets bigger, then you want to delete the constraint that says that button1 must be exactly 20 points wide.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment