Fixed cell width - unable to simultaneously satisfy constraints - ios

Just making my first steps in IOS development, and I want to bring my Android app to IOS.
The issue it with UICollectionView. I need the cells to be of fixed constant width, and the image inside the cell - of fixed height. So, I've set the width constraint of StackView to 105 and height constraint for ImageView to 147.
Everything looks as expected, however I get warnings in the console:
2021-02-21 22:23:17.490472+0200 myapp-ios[20727:783655] [LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x600002193890 UIStackView:0x7f90efc173d0.width == 105 (active)>",
"<NSLayoutConstraint:0x6000021938e0 H:[UIStackView:0x7f90efc173d0]-(0)-| (active, names: '|':UIView:0x7f90efc1d840 )>",
"<NSLayoutConstraint:0x600002193930 H:|-(0)-[UIStackView:0x7f90efc173d0] (active, names: '|':UIView:0x7f90efc1d840 )>",
"<NSLayoutConstraint:0x600002193a20 'UIIBSystemGenerated' myapp_ios.ShowCell:0x7f90efc23ec0.leading == UIView:0x7f90efc1d840.leading (active)>",
"<NSLayoutConstraint:0x600002193a70 'UIIBSystemGenerated' H:[UIView:0x7f90efc1d840]-(0)-| (active, names: '|':myapp_ios.ShowCell:0x7f90efc23ec0 )>",
"<NSLayoutConstraint:0x6000021967b0 'UIView-Encapsulated-Layout-Width' myapp_ios.ShowCell:0x7f90efc23ec0.width == 50 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002193890 UIStackView:0x7f90efc173d0.width == 105 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
I also tried to set width and height constraints of ImageView only to 105x147, it looks the same, and the warning is pretty much the same. Basically if no width or height constraints set - there is no warning, once I add any of them - it appears.
Here are the constraints:
I would appreciate you helping me understand the potential problem.

I think removing the width constraint of the stack view will work.

Related

"Unable to simultaneously satisfy constraints" with UITableViewCell

I used the Interface Builder to create a pretty simple layout inside a UITableViewCell for my Xcode 13.0/Swift 5/iOS 13.5 app:
UIStackView (with 2 UIViews and UILabels inside) at the top and a UIView (with a UIImageView inside) below it.
The exact constraints are currently:
UIStackView: 10pts leading, 10pts trailing, 0pts top, 10pts to the UIView at the bottom, height of 50pts
UIView: 20pts leading, 20pts trailing, 10pts bottom, (10pts top from the UIStackView), height=width
UIImageView inside the UIView: 0pts leading/trailing/top/bottom, align center x to Superview (=UIView)
Contrary to other questions about the warning here on stackoverflow I don't set the UITableViewCell's height directly but want it to be set by its content. The UIImageView's image is set at runtime and should keep its shape, so square images should be square and the other rectangular images should be centered horizontally (-> invisible bars left/right, if necessary) but not vertically.
Xcode doesn't complain about missing constraints but this layout keeps giving me the infamous "Unable to simultaneously satisfy constraints" warning.
[LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x600002d22d50 UIStackView:0x7fe4fa293330.height == 50 (active)>",
"<NSLayoutConstraint:0x600002d22df0 UIView:0x7fe4fa29d1c0.height == UIView:0x7fe4fa29d1c0.width (active)>",
"<NSLayoutConstraint:0x600002d23070 V:|-(0)-[UIStackView:0x7fe4fa293330] (active, names: '|':UITableViewCellContentView:0x7fe4fa2840f0 )>",
"<NSLayoutConstraint:0x600002d23110 H:[UIView:0x7fe4fa29d1c0]-(20)-| (active, names: '|':UITableViewCellContentView:0x7fe4fa2840f0 )>",
"<NSLayoutConstraint:0x600002d23160 V:[UIStackView:0x7fe4fa293330]-(10)-[UIView:0x7fe4fa29d1c0] (active)>",
"<NSLayoutConstraint:0x600002d231b0 H:|-(20)-[UIView:0x7fe4fa29d1c0] (active, names: '|':UITableViewCellContentView:0x7fe4fa2840f0 )>",
"<NSLayoutConstraint:0x600002d23200 V:[UIView:0x7fe4fa29d1c0]-(10)-| (active, names: '|':UITableViewCellContentView:0x7fe4fa2840f0 )>",
"<NSLayoutConstraint:0x600002d36530 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fe4fa2840f0.height == 325.5 (active)>",
"<NSLayoutConstraint:0x600002d364e0 'UIView-Encapsulated-Layout-Width' UITableViewCellContentView:0x7fe4fa2840f0.width == 295 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002d22df0 UIView:0x7fe4fa29d1c0.height == UIView:0x7fe4fa29d1c0.width (active)>
I already checked with wtfautolayout.com but the only thing wrong that I can see is the height: If the width is 295, then the height should be exactly 50+10+295-40+10=325 (UIStackView.height + constraint in-between + UIView.width - leading/trailing constraints + bottom constraint), not 325.5. Everything else looks fine to me, so I'm not sure why it would calculate that wrong height (and if that's even the problem).
I already tried a couple of things:
Added the UIStackView's fixed height (didn't use it before everything looked fine and it didn't complain about it, still got the warning though)
UIView.width = UIImageView.height (1:1 aspect ratio, instead of the one above)
UIImageView.width = UIImageView.height (1:1 aspect ratio, instead of the one above)
Removed the "center x" constraint
Nothing worked, I keep getting the constraint warning and if it doesn't show up in portrait mode because of something I changed, then it does as soon as I switch to landscape mode. How do I fix this in IB/without code?
Try changing the priority of the height=width constraint to High instead of Required

Unable to simultaneously satisfy constraints. Probably at least one of the constraints

I'm doing an ios chat application using swift 5 and storyboard, one of my views contain a table view and cell however i'm getting this kind of error i didn't udnerstand what is it exacctly and how can i fix it!
Apparently whenever the tableView.reload() function is called this problem happens.
Here it is my view
view storyboard tableview
As you can see in the image there is a tableview, and within the tableCell, there is a view that contain label to display username, and in the right an image view to display user photo
2020-10-14 14:59:17.638363+0200 Chatiw[17620:455807] [LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x6000000e7840 UILabel:0x7fafbe739be0.width >= 261 (active)>",
"<NSLayoutConstraint:0x6000000e7930 UIImageView:0x7fafbe73a4d0.width == 62 (active)>",
"<NSLayoutConstraint:0x6000000e7b10 UILabel:0x7fafbe739be0.leading >= UITableViewCellContentView:0x7fafbe739850.leadingMargin (active)>",
"<NSLayoutConstraint:0x6000000e7c50 H:[UILabel:0x7fafbe739be0]-(51)-[UIImageView:0x7fafbe73a4d0] (active)>",
"<NSLayoutConstraint:0x6000000e7ca0 UIImageView:0x7fafbe73a4d0.trailing == UITableViewCellContentView:0x7fafbe739850.trailingMargin (active)>",
"<NSLayoutConstraint:0x600000096580 'UIView-Encapsulated-Layout-Width' UITableViewCellContentView:0x7fafbe739850.width == 375 (active)>",
"<NSLayoutConstraint:0x6000000e7e80 'UIView-leftMargin-guide-constraint' H:|-(16)-[UILayoutGuide:0x600001a9cb60'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':UITableViewCellContentView:0x7fafbe739850 )>",
"<NSLayoutConstraint:0x6000000e7f20 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001a9cb60'UIViewLayoutMarginsGuide']-(16)-|(LTR) (active, names: '|':UITableViewCellContentView:0x7fafbe739850 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000000e7840 UILabel:0x7fafbe739be0.width >= 261 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-10-14 14:59:17.642314+0200 Chatiw[17620:455807] [LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x600000096710 UILabel:0x7fafbe43e0f0.width >= 261 (active)>",
"<NSLayoutConstraint:0x6000000968f0 UIImageView:0x7fafbe43e360.width == 62 (active)>",
"<NSLayoutConstraint:0x6000000ea620 UILabel:0x7fafbe43e0f0.leading >= UITableViewCellContentView:0x7fafbe43dd60.leadingMargin (active)>",
"<NSLayoutConstraint:0x6000000eb8e0 H:[UILabel:0x7fafbe43e0f0]-(51)-[UIImageView:0x7fafbe43e360] (active)>",
"<NSLayoutConstraint:0x6000000eb7f0 UIImageView:0x7fafbe43e360.trailing == UITableViewCellContentView:0x7fafbe43dd60.trailingMargin (active)>",
"<NSLayoutConstraint:0x600000097250 'UIView-Encapsulated-Layout-Width' UITableViewCellContentView:0x7fafbe43dd60.width == 375 (active)>",
"<NSLayoutConstraint:0x6000000eb9d0 'UIView-leftMargin-guide-constraint' H:|-(16)-[UILayoutGuide:0x600001a9a5a0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':UITableViewCellContentView:0x7fafbe43dd60 )>",
"<NSLayoutConstraint:0x6000000eac60 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001a9a5a0'UIViewLayoutMarginsGuide']-(16)-|(LTR) (active, names: '|':UITableViewCellContentView:0x7fafbe43dd60 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000096710 UILabel:0x7fafbe43e0f0.width >= 261 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-10-14 14:59:17.644909+0200 Chatiw[17620:455807] [LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x6000000eb930 UILabel:0x7fafc084b7c0.width >= 261 (active)>",
"<NSLayoutConstraint:0x6000000ea8f0 UIImageView:0x7fafc084bb60.width == 62 (active)>",
"<NSLayoutConstraint:0x6000000eab20 UILabel:0x7fafc084b7c0.leading >= UITableViewCellContentView:0x7fafc084b630.leadingMargin (active)>",
"<NSLayoutConstraint:0x6000000ea8a0 H:[UILabel:0x7fafc084b7c0]-(51)-[UIImageView:0x7fafc084bb60] (active)>",
"<NSLayoutConstraint:0x6000000ea990 UIImageView:0x7fafc084bb60.trailing == UITableViewCellContentView:0x7fafc084b630.trailingMargin (active)>",
"<NSLayoutConstraint:0x6000000cf700 'UIView-Encapsulated-Layout-Width' UITableViewCellContentView:0x7fafc084b630.width == 375 (active)>",
"<NSLayoutConstraint:0x6000000d3250 'UIView-leftMargin-guide-constraint' H:|-(16)-[UILayoutGuide:0x600001a9a760'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':UITableViewCellContentView:0x7fafc084b630 )>",
"<NSLayoutConstraint:0x6000000d2df0 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001a9a760'UIViewLayoutMarginsGuide']-(16)-|(LTR) (active, names: '|':UITableViewCellContentView:0x7fafc084b630 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000000eb930 UILabel:0x7fafc084b7c0.width >= 261 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-10-14 14:59:17.647864+0200 Chatiw[17620:455807] [LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x6000000efb60 UILabel:0x7fafc0d0a3d0.width >= 261 (active)>",
"<NSLayoutConstraint:0x6000000d2da0 UIImageView:0x7fafc084c430.width == 62 (active)>",
"<NSLayoutConstraint:0x6000000d3b60 UILabel:0x7fafc0d0a3d0.leading >= UITableViewCellContentView:0x7fafc0d09aa0.leadingMargin (active)>",
"<NSLayoutConstraint:0x6000000d3840 H:[UILabel:0x7fafc0d0a3d0]-(51)-[UIImageView:0x7fafc084c430] (active)>",
"<NSLayoutConstraint:0x6000000d37a0 UIImageView:0x7fafc084c430.trailing == UITableViewCellContentView:0x7fafc0d09aa0.trailingMargin (active)>",
"<NSLayoutConstraint:0x6000000eac10 'UIView-Encapsulated-Layout-Width' UITableViewCellContentView:0x7fafc0d09aa0.width == 375 (active)>",
"<NSLayoutConstraint:0x6000000d05f0 'UIView-leftMargin-guide-constraint' H:|-(16)-[UILayoutGuide:0x600001a9a840'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':UITableViewCellContentView:0x7fafc0d09aa0 )>",
"<NSLayoutConstraint:0x6000000d3f20 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001a9a840'UIViewLayoutMarginsGuide']-(16)-|(LTR) (active, names: '|':UITableViewCellContentView:0x7fafc0d09aa0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000000efb60 UILabel:0x7fafc0d0a3d0.width >= 261 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-10-14 14:59:17.650367+0200 Chatiw[17620:455807] [LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x6000000978e0 UILabel:0x7fafbe442740.width >= 261 (active)>",
"<NSLayoutConstraint:0x6000000979d0 UIImageView:0x7fafbe4429b0.width == 62 (active)>",
"<NSLayoutConstraint:0x600000097bb0 UILabel:0x7fafbe442740.leading >= UITableViewCellContentView:0x7fafbe4425b0.leadingMargin (active)>",
"<NSLayoutConstraint:0x600000097cf0 H:[UILabel:0x7fafbe442740]-(51)-[UIImageView:0x7fafbe4429b0] (active)>",
"<NSLayoutConstraint:0x600000097d40 UIImageView:0x7fafbe4429b0.trailing == UITableViewCellContentView:0x7fafbe4425b0.trailingMargin (active)>",
"<NSLayoutConstraint:0x60000009c780 'UIView-Encapsulated-Layout-Width' UITableViewCellContentView:0x7fafbe4425b0.width == 375 (active)>",
"<NSLayoutConstraint:0x600000097f20 'UIView-leftMargin-guide-constraint' H:|-(16)-[UILayoutGuide:0x600001ade840'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':UITableViewCellContentView:0x7fafbe4425b0 )>",
"<NSLayoutConstraint:0x6000000efc00 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001ade840'UIViewLayoutMarginsGuide']-(16)-|(LTR) (active, names: '|':UITableViewCellContentView:0x7fafbe4425b0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000000978e0 UILabel:0x7fafbe442740.width >= 261 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Anyone please can explain to me exactly what is this problem so i can understand it and how can i fix it? i already have this problem on all my table views!
It's incredibly difficult to solve these problems or warnings.
Here is ONE KEY TIP.
You can actually add a name to EVERY! constraint.
Do so.
Make the name clear and obvious like "the top constraint on the second box" or whatever.
You don't have to do every single constraint in the app, just the possibly problem ones in the relevant region.
Before anything else, you have to do that. :/
Note that there is a vast amount of discussions about this on this site, 100s of questions, eg https://stackoverflow.com/a/31833436/294884
Essentially, "your constraints have a minor problem" and specifically you likely have "one too many constraints somewhere" (or more subtly, you have to change the priority on one).
Your first step is the naming trick, to at least find out what the hell constraints Apple is referring to :/
Some suggest this BTW! http://wtfautolayout.com
For this particular question:
In this particular case, of the many, many possible problems, it turns out the OP's problem was the "two constraints" issue:
If you DO have/need two constraints, then ONE of them MUST have a DIFFERENT priority than the other.
It is a bit of hard to answer without a UI example (both the ViewController and the Cell). But it seems that the TableViewCell subviews constraints are not complying with the actual width of the cell.
You set a bigger width constraints to the label and image view distances and sizes than there is space in the screen.
An example that might work for you:
[-(leading=0)-(label)-(<=50)-(imageView=60)-(trailing=0)-]
This way there will be a minimum of 50 points constraints between the imageView and the label...
Several Suggestions:
No need to set a width constrain on the label - it should be infer from the actual text in it, just describe (with constraints) the distance to other views.
No need for setting a width/height constraints on the imageView at all and see the contentMode property for how to adapt the image in it.
Unless you want to centre the subviews within the cell, no need to set leading/trailing constraints as >= / <= just pin them to the super view (the cell in your case)
Another tip is if the label might contain a long string is to set its numberOfLines property to 0.
And set self.tableView.rowHeight = UITableViewAutomaticDimension
See this awesome explanation about TableViewCell constraints

Silencing constraint errors when hiding table view cell

I have a tableview which has a label inside each cell:
I have set three constraints for the label:
I am hiding some of the cells in code based on some condition by setting the height to zero and setting their isHidden property to true and when that happens, I get this in console:
[LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x282c606e0 UILabel:0x157edf690'0'.top == UITableViewCellContentView:0x157edf250.topMargin + 2.5 (active)>",
"<NSLayoutConstraint:0x282c60730 UITableViewCellContentView:0x157edf250.bottomMargin == UILabel:0x157edf690'0'.bottom + 2.5 (active)>",
"<NSLayoutConstraint:0x282c60870 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x2836915e0'UIViewLayoutMarginsGuide']-(8)-| (active, names: '|':UITableViewCellContentView:0x157edf250 )>",
"<NSLayoutConstraint:0x282c60e10 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x157edf250.height == 0 (active)>",
"<NSLayoutConstraint:0x282c607d0 'UIView-topMargin-guide-constraint' V:|-(8)-[UILayoutGuide:0x2836915e0'UIViewLayoutMarginsGuide'] (active, names: '|':UITableViewCellContentView:0x157edf250 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x282c60730 UITableViewCellContentView:0x157edf250.bottomMargin == UILabel:0x157edf690'0'.bottom + 2.5 (active)>
now I have two questions:
1- Is it safe to ignore this warning?
2- I know that it may help to lower the priority in one of the constraints. but which one should it be and why?

iOS Autolayout: Is it okay to set constraint priority to 999 to silence a warning?

I am getting the following warning with auto layout.
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.
(
"<NSLayoutConstraint:0x604000285230 H:|-(64)-[UILabel:0x7fc908d51ba0] (active, names: '|':UIView:0x7fc908d52020 )>",
"<NSLayoutConstraint:0x6040002854b0 H:[UIView:0x7fc908c59f60]-(0)-| (active, names: '|':UIView:0x7fc908d52020 )>",
"<NSLayoutConstraint:0x604000285000 H:[UILabel:0x7fc908d51ba0]-(9)-[UIView:0x7fc908c59f60] (active)>",
"<NSLayoutConstraint:0x6040002855f0 UIView:0x7fc908c59f60.width == 160 (active)>",
"<NSLayoutConstraint:0x60400028a1e0 'UIView-Encapsulated-Layout-Width' UIView:0x7fc908d52020.width == 0 (active)>"
)
However, I am able to silence the warning by setting the trailing constraint priority to 999. This seems to remove the warning and nothing regarding the layout changed. Is this okay to do or can this cause any issues?
Is this okay to do or can this cause any issues?
Depends. Might cause issues.
The ideal way is to not disrupt you constraints to fix warnings. The issue seems to be with constraints.
"<NSLayoutConstraint:0x60400028a1e0 'UIView-Encapsulated-Layout-Width' UIView:0x7fc908d52020.width == 0 (active)>"
Your superview (0x7fc908d52020), is forcing a width of 0. Probably something you do not want.

Xcode Swift: Why is it breaking my Constraints?

I'm just learning Swift with the Start Developing iOS Apps (Swift) Tutorial. I'm creating this custom Rating Control but every time i run the App is sends following Error:
2017-08-09 15:49:41.894597+0200 FoodTracker[5051:2273797] [LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x17409af90 UIButton:0x100c12d90.width == 44 (active)>",
"<NSLayoutConstraint:0x17009c160 'UISV-canvas-connection' FoodTracker.RatingControl:0x100c02400.leading == UIButton:0x100c12d90.leading (active)>",
"<NSLayoutConstraint:0x17009c200 'UISV-canvas-connection' H:[UIButton:0x100c12d90]-(0)-| (active, names: '|':FoodTracker.RatingControl:0x100c02400 )>",
"<NSLayoutConstraint:0x17009bee0 'UIView-Encapsulated-Layout-Width' FoodTracker.RatingControl:0x100c02400.width == 343 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17409af90 UIButton:0x100c12d90.width == 44 (active)>
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.
2017-08-09 15:49:41.895770+0200 FoodTracker[5051:2273797] [LayoutConstraints] 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.
(
"<NSLayoutConstraint:0x17409af40 UIButton:0x100c12d90.height == 44 (active)>",
"<NSLayoutConstraint:0x17009c250 'UISV-canvas-connection' FoodTracker.RatingControl:0x100c02400.top == UIButton:0x100c12d90.top (active)>",
"<NSLayoutConstraint:0x17009c340 'UISV-canvas-connection' V:[UIButton:0x100c12d90]-(0)-| (active, names: '|':FoodTracker.RatingControl:0x100c02400 )>",
"<NSLayoutConstraint:0x17009bf30 'UIView-Encapsulated-Layout-Height' FoodTracker.RatingControl:0x100c02400.height == 50 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17409af40 UIButton:0x100c12d90.height == 44 (active)>
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 set the constraints for Button width == 44 and for Button height == 44, but none of the other constraints. I did everything as described in the Tutorial and have no clue why it doesn't work. I Checked all Constraints i can find but i'm not sure if it were all as I'm not very experienced with Xcode. Do anyone have a clue how to solve the Problem?
This is how it should look like: But this is how it looks: (Only The Red Area is important)
I also faced similar issue. The solution is simple, as shown, move (drag and drop) horizontal stack view under the vertical stack view as shown.
Based on the error message, I think you have embedded the button inside a UIStackView. The stack view has incorrect constraints, or no constraints at all and is using the autoresizing mask. The stack view is being given a size of 343x50 and is forcing the button to match.
Looks like you have a UIStackView. Remove the UIButton out of the UIStackView and set that UIButton's top constraint the same spacing you defined in your UIStackView and set the UIButton's align leading edge to the UiStackView and you're good
I have found reason and solution.
Horizontal Stack View - filling whole own internal space by vertical and horizontal. It's mean - Horizontal Stack View will set height and wight for internal items to Fill all available space.
Only way to remove such warning which i found - is set width/height of Horizontal Stack View to fit perfectly with/height of all internal elements: 252x44

Resources