Unable to simultaneously satisfy constraints. - ios

Can anybody help me understanding this Autolayout exception?
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)
(
"<NSLayoutConstraint:0x7f9b3c030f30 H:[UIImageView:0x7f9b3c042530(80)]>",
"<NSLayoutConstraint:0x7f9b3c04c980 UIImageView:0x7f9b3c042530.leading == UIView:0x7f9b39ef83e0.leadingMargin - 8>",
"<NSLayoutConstraint:0x7f9b3c03be80 H:[UIImageView:0x7f9b3c042530]-(8)-[UILabel:0x7f9b3c03c520'Distance']>",
"<NSLayoutConstraint:0x7f9b39ef6d30 H:[UILabel:0x7f9b3c03c520'Distance']-(9)-[UILabel:0x7f9b3c03c330'Hip Hop']>",
"<NSLayoutConstraint:0x7f9b39ecdf60 UILabel:0x7f9b3c03c330'Hip Hop'.width == UILabel:0x7f9b39eef850'Price'.width>",
"<NSLayoutConstraint:0x7f9b39ecdfb0 UILabel:0x7f9b3c03c330'Hip Hop'.width == UILabel:0x7f9b3c03c520'Distance'.width>",
"<NSLayoutConstraint:0x7f9b39eed730 H:[UILabel:0x7f9b3c03c330'Hip Hop']-(9)-[UILabel:0x7f9b39eef850'Price']>",
"<NSLayoutConstraint:0x7f9b39eed780 UIView:0x7f9b39ef83e0.trailingMargin == UILabel:0x7f9b39eef850'Price'.trailing - 3>",
"<NSAutoresizingMaskLayoutConstraint:0x7f9b39edf060 h=--& v=--& H:[UIView:0x7f9b39ef83e0(50)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f9b3c030f30 H:[UIImageView:0x7f9b3c042530(80)]>
Help Appreciated.

Whatever the view is that you're adding in code you should add the line...
imageView.translatesAutoresizingMaskIntoConstraints = NO;

Related

Programmatically Setting Constraints Causes Conflict in Swift

As i posted in this GitHub issue, I am having trouble with some hidden constraints that throw an error whenever I try to add my own constraints
2016-04-18 19:22:04.270 Metric Time[1519:447809] 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)
(
"<NSAutoresizingMaskLayoutConstraint:0x15e670e70 h=--& v=--& Metric_Time.View:0x15e692e70.midX == + 115>",
"<NSLayoutConstraint:0x15e5048c0 Metric_Time.View:0x15e692e70.centerX == UIView:0x15e6953e0.centerX>",
"<NSAutoresizingMaskLayoutConstraint:0x15e55fd30 h=-&- v=-&- 'UIView-Encapsulated-Layout-Left' H:|-(0)-[UIView:0x15e6953e0] (Names: '|':UIWindow:0x15e688ed0 )>",
"<NSLayoutConstraint:0x15e54e750 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15e6953e0(320)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x15e5048c0 Metric_Time.View:0x15e692e70.centerX == UIView:0x15e6953e0.centerX>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.`
I have tried looking for the places that these constraints could have been created, but searching my ViewController.swift file for keywords such as constraint, layout .etc turned up only the code that I wrote.
My code is all on GitHub if anyone wants to mess around with it.
If you are going to add constraints programmatically, you need to turn off translateAutoresizingMaskIntoConstraints. You also don't have enough constraints to satisfy the layout engine. Remember that UIView's don't have an intrinsic size and if you are using auto layout with a view you need to set everything with constraints and not rely on a mixture of constraints and frames. one possible solution is to add some code like:
self.view.addSubview(clockView)
clockView.translatesAutoresizingMaskIntoConstraints = false
clockView.centerYAnchor.constraintEqualToAnchor(self.view.centerYAnchor, constant: 0.0).active = true
clockView.centerXAnchor.constraintEqualToAnchor(self.view.centerXAnchor, constant: 0.0).active = true
clockView.widthAnchor.constraintEqualToConstant(230.0).active = true
clockView.heightAnchor.constraintEqualToConstant(230.0).active = true
However this is not exactly what you want as when it is in landscape your clock overlays your label. But you could fix that by playing with clockView.centerYAnchor.constraintEqualToAnchor(self.view.centerYAnchor, constant: 0.0).active = true

getting weird log message on console(AutoLayout)

Hiii Guys,
I have a view with 600*450 size, now i put a collection view in a view with 600*430 size. when i am running application i am getting this weird message on console
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)
(
"<NSLayoutConstraint:0x600000285960 V:|-(0)-[UICollectionView:0x7fb133860800] (Names: '|':UIView:0x60000019df60 )>",
"<NSLayoutConstraint:0x600000285a50 V:[UICollectionView:0x7fb133860800]-(20)-| (Names: '|':UIView:0x60000019df60 )>",
"<NSLayoutConstraint:0x600000285dc0 V:[_UILayoutGuide:0x6000001b5b60]-(0)-[UIView:0x60000019dc20]>",
"<NSLayoutConstraint:0x600000285e10 UIView:0x60000019dc20.height == 0.25*UIView:0x60000019db50.height>",
"<NSLayoutConstraint:0x6000002860e0 V:[_UILayoutGuide:0x6000001b5b60]-(0)-[UIView:0x60800019d5a0]>",
"<NSLayoutConstraint:0x600000286180 UIView:0x60000019df60.bottom == UIView:0x60000019ddc0.bottom>",
"<NSLayoutConstraint:0x600000286220 UIView:0x60000019df60.top == UIView:0x60800019d5a0.top>",
"<NSLayoutConstraint:0x600000286540 UIView:0x60000019dcf0.height == 0.25*UIView:0x60000019db50.height>",
"<NSLayoutConstraint:0x600000286590 V:[UIView:0x60000019dc20]-(0)-[UIView:0x60000019dcf0]>",
"<NSLayoutConstraint:0x6000002867c0 UIView:0x60000019ddc0.height == 0.25*UIView:0x60000019db50.height>",
"<NSLayoutConstraint:0x6000002868b0 V:[UIView:0x60000019dcf0]-(0)-[UIView:0x60000019ddc0]>",
"<NSLayoutConstraint:0x600000288d40 'UIView-Encapsulated-Layout-Height' V:[UIView:0x60000019db50(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000285a50 V:[UICollectionView:0x7fb133860800]-(20)-| (Names: '|':UIView:0x60000019df60 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
i don't know what to do.
I have applied this 4 constraints to UICollectionView.
This occur because few constraint you have added is not required so it is better to select the view and then after Choose Reset to suggested constraint .
and if after this if constraint not up to mark then better to look for each control constraint and check which constraint showing mark (yellow)and try to remove manually and then add.
Hope it helps.

How can I detect the views whose constraints are being unsatisfied?

I am constantly getting this error:
2014-09-13 23:56:19.904 Parrot[245:60b] 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)
(
"<NSLayoutConstraint:0x14641170 H:[UILabel:0x14641060(200)]>",
"<NSLayoutConstraint:0x14643670 H:[UILabel:0x14641060]-(60)-| (Names: '|':UIView:0x14641590 )>",
"<NSLayoutConstraint:0x146436a0 H:|-(60)-[UILabel:0x14641060] (Names: '|':UIView:0x14641590 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1464bc70 h=--& v=--& H:[UIView:0x14641590(480)]>"
)
How can I detect the views whose constraints are being unsatisfied?
[UILabel:0x14641060]
It's in error message.
It seems this UILabel has three constraints. Remove any one of these you can satisfy the constraints

iOS: Unable to simultaneously satisfy constraints

I've seen the common response to this question of not having constraints set up properly. However, I've worked through all of the ambiguities in Interface Builder, and all constraints seem OK. I'm not sure what to check next. I can't even tell where it is coming from. I'm not setting any constraints in code.
What can I do to figure out where it is coming form?
What can be the cause if Interface Builder doesn't report any ambiguities?
Here's the specific error:
2014-06-28 19:54:36.070 Prayer Feed[4497:60b] 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)
(
"<NSLayoutConstraint:0x178290360 H:[UIImageView:0x13ee32490(20)]>",
"<NSLayoutConstraint:0x1782904f0 UITableViewCellContentView:0x178166840.centerX == UIImageView:0x13ee32490.centerX + 62>",
"<NSLayoutConstraint:0x178290540 H:|-(52)-[UIImageView:0x13ee32490] (Names: '|':UITableViewCellContentView:0x178166840 )>",
"<NSAutoresizingMaskLayoutConstraint:0x170286d60 h=--& v=--& H:[UITableViewCellContentView:0x178166840(247)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x178290360 H:[UIImageView:0x13ee32490(20)]>
I know the two place in code where I have a UIImageView constrained to 20x20, but again, IB tells me everything is fine.
This is the part where the problem is:
<NSAutoresizingMaskLayoutConstraint:0x170286d60 h=--& v=--& H:[UITableViewCellContentView:0x178166840(247)]>
This mask needs to be turned off.
I think that mask is off by default for IB elements that have constraints. So I assume you made something in code. You can turn it off in code like this:
contentView.translatesAutoresizingMaskIntoConstraints = NO
If this is really all IB only then I would like to know what code you use around creating table cells.

Unable to simultaneously satisfy constraints, where is it coming from?

I have this warning when building my app. I'm using a storyboard, but all constraints are proper over there.. I don't know where else I have to look..
2014-04-29 14:18:54.072 gTicket[1540:60b] 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)
(
"<NSLayoutConstraint:0x16593a90 V:[UIView:0x165a1dd0(429)]>",
"<NSLayoutConstraint:0x165b3c50 V:[UILabel:0x165b3d80(20)]>",
"<NSLayoutConstraint:0x165b37c0 V:[UIView:0x165945a0(52)]>",
"<NSLayoutConstraint:0x165ac960 V:[_UILayoutGuide:0x165a8670]-(36)-[UIView:0x165a1dd0]>",
"<NSLayoutConstraint:0x165a9060 V:[UIView:0x165a1dd0]-(14)-[UILabel:0x165b3d80]>",
"<NSLayoutConstraint:0x165b50d0 V:[UILabel:0x165b3d80]-(16)-[UIView:0x165945a0]>",
"<NSLayoutConstraint:0x165a1e80 V:[UIView:0x165945a0]-(1)-[_UILayoutGuide:0x165adfc0]>",
"<_UILayoutSupportConstraint:0x165adf00 V:[_UILayoutGuide:0x165a8670(0)]>",
"<_UILayoutSupportConstraint:0x165ae3b0 V:|-(0)-[_UILayoutGuide:0x165a8670] (Names: '|':UIView:0x165a6940 )>",
"<_UILayoutSupportConstraint:0x1659c120 V:[_UILayoutGuide:0x165adfc0(0)]>",
"<_UILayoutSupportConstraint:0x165a12d0 _UILayoutGuide:0x165adfc0.bottom == UIView:0x165a6940.bottom>",
"<NSAutoresizingMaskLayoutConstraint:0x165baf00 h=--& v=--& V:[UIView:0x165a6940(431)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x16593a90 V:[UIView:0x165a1dd0(429)]>
Is it possible to determine which UILabel and which view it is complaining about?

Resources