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
Related
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.
In Session 204 of the 2017 WWDC it was mentioned that you can now use Auto Layout in the UIViewController navigationItem.titleView.
I tried various different options including the mentioned intrinsicContentSIze, custom view with custom frame as well as a complete Auto Layout approach with fixed height.
No matter what I do, the navigation bar always shrinks down my views to 44 points.
Furthermore when using the AutoLayout only approach, I'm getting this constraint error:
14:03:41.049847+0800 dfgd[60535:11623968] [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:0x600000092a70 UILayoutGuide:0x6000001b3160'TitleView(0x7f8beb6061c0)'.height == 44 (active)>",
"<NSLayoutConstraint:0x600000092250 UIView:0x7f8beb602f50.height == 200 (active)>",
"<NSLayoutConstraint:0x6000000920c0 V:[UIView:0x7f8beb602f50]-(10)-| (active, names: '|':dfgd.CustomView:0x7f8beb602930 )>",
"<NSLayoutConstraint:0x6000000925c0 UIView:0x7f8beb602f50.centerY == dfgd.CustomView:0x7f8beb602930.centerY (active)>",
"<NSLayoutConstraint:0x6040000938d0 dfgd.CustomView:0x7f8beb602930.top >= UILayoutGuide:0x6000001b3160'TitleView(0x7f8beb6061c0)'.top (active)>",
"<NSLayoutConstraint:0x604000094a50 dfgd.CustomView:0x7f8beb602930.bottom <= UILayoutGuide:0x6000001b3160'TitleView(0x7f8beb6061c0)'.bottom (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000092250 UIView:0x7f8beb602f50.height == 200 (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.
QUESTION:
Has anybody managed to make that work? How do you get custom navigation bar heights to adopt to your title views?
I'm trying something really simple and I do not understand the constraint conflict resulting. Let me explain:
I have a nice view controller with a full screen vertical UIStackView (contraints set to 0 to top, leading, trailing and bottom) with two views inside.
The top view as a constrained height of 200pt, the bottom view has no constraint. As the stack view has a Fill distribution mode, everything is fine.
Now, I want the stack view to switch to horizontal axis on landscape on iPhones. So, on my storyboard I select the wAny|hCompact size class, uninstall the height constraint, add a width constraint, and select horizontal axis...
The behavior works alright, unfortunately, it detects a constraint conflict I can't explain :
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:0x7fba62c1b7f0 H:[UIStackView:0x7fba62c0a3c0]-(0)-| (Names: '|':UIView:0x7fba62c0bd10 )>",
"<NSLayoutConstraint:0x7fba62c1b890 H:|-(0)-[UIStackView:0x7fba62c0a3c0] (Names: '|':UIView:0x7fba62c0bd10 )>",
"<NSLayoutConstraint:0x7fba62c1ba80 H:[UIView:0x7fba62c15420(200)]>",
"<NSLayoutConstraint:0x7fba62d1c230 'UISV-canvas-connection' UIStackView:0x7fba62c0a3c0.leading == UIView:0x7fba62c15420.leading>",
"<NSLayoutConstraint:0x7fba62dcad80 'UISV-canvas-connection' H:[UIView:0x7fba62c15420]-(0)-| (Names: '|':UIStackView:0x7fba62c0a3c0 )>",
"<NSLayoutConstraint:0x7fba62dc69d0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fba62c0bd10(736)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fba62c1ba80 H:[UIView:0x7fba62c15420(200)]>
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.
So if someone can tell me what is wrong!
Ran into this problem and it appears to possibly be a bug in UIStackView where an internally generated constraint from the previous/default size class is lingering. This workaround (Swift) works for me:
override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
self.setNeedsLayout()
self.layoutIfNeeded()
}
In my app I have custom tableViewCells with a fixed ratio (16x9). To achieve that, I placed a view in the cell, fixed it to its parent view (although I did it in interface builder: V/H:|-[innerView]-|).
Also, I put a ratio constraint on it.
In my tableViewController I'm using UITableViewAutomaticDimension as a table cell height.
The estimated row height is 180, wich is the exact size the cell will have on a 320px wide display (as I, as you can see, do).
I'm still deploying for 8.4, but when running the project on an Device with iOS 9, I'm getting tons of auto layout warnings, although everything works fine and looks perfect.
The warning itself is absolutely right. There are two constraints I don't want – these that iOS added on its own.
2015-09-29 11:24:57.771 app[1039:324736] 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:0x147d3e0d0 UIView:0x14901ff70.height == 0.5625*UIView:0x14901ff70.width>",
"<NSLayoutConstraint:0x147dd0210 H:|-(0)-[UIView:0x14901ff70] (Names: '|':UITableViewCellContentView:0x14901f960 )>",
"<NSLayoutConstraint:0x147deeca0 V:|-(0)-[UIView:0x14901ff70] (Names: '|':UITableViewCellContentView:0x14901f960 )>",
"<NSLayoutConstraint:0x149053c30 V:[UIView:0x14901ff70]-(0)-| (Names: '|':UITableViewCellContentView:0x14901f960 )>",
"<NSLayoutConstraint:0x147dbc2b0 H:[UIView:0x14901ff70]-(0)-| (Names: '|':UITableViewCellContentView:0x14901f960 )>",
"<NSLayoutConstraint:0x149070800 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x14901f960(179.5)]>",
"<NSLayoutConstraint:0x1490707b0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x14901f960(320)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x147d3e0d0 UIView:0x14901ff70.height == 0.5625*UIView:0x14901ff70.width>
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.
The only thing I see here are the missing 0.5 pixels that iOS subtracted somehow magically.
The issue is the two constraints that the tableview adds automatically. UIView-Encapsulated-Layout-Height and width are probably the height and width the table view calculated for the cell during the initial load, based on the cell's constraints at that time.
"<NSLayoutConstraint:0x149070800 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x14901f960(179.5)]>",
"<NSLayoutConstraint:0x1490707b0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x14901f960(320)]>"
As the priorities for these constraints are 1000 what you can do is lower your height and width constraint priorities and let the encapsulated size to be applied when needed (at load).
Seems you have added two ratio constraints added on two different views.
One that should be there is,
<NSLayoutConstraint:0x14d939e00 UIView:0x14da107f0.width ==
1.77778*UIView:0x14da107f0.height>
has memory address 0x14d939e00 added on UIView with address 0x14da107f0.
The other one is breaking.
<NSLayoutConstraint:0x14c5eae90 UIView:0x14c5ead30.height ==
0.5625*UIView:0x14c5ead30.width>
This one is added on a UIView (0x14c5ead30). Look for this view and remove this ratio constraint.
I am trying to implement a feed of news (somehow like instagram without comments or likes). It works, but xcode keep showing this error. I tried change all the constraints, however, I cant get to work. The tableview has a height of 475 and the image has the height of 400, leaving 75 for the white area with labels.
I did use
self.tableView.estimatedRowHeight = 475;
self.tableView.rowHeight = UITableViewAutomaticDimension;
Any help?
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:0x174096530 UIImageView:0x1743e9000.top == UITableViewCellContentView:0x17418af80.topMargin + 13>",
"<NSLayoutConstraint:0x1740977f0 V:[PFImageView:0x1743e8e00]-(0)-| (Names: '|':UITableViewCellContentView:0x17418af80 )>",
"<NSLayoutConstraint:0x174097840 V:[UIImageView:0x1743e9000]-(24)-[PFImageView:0x1743e8e00]>",
"<NSLayoutConstraint:0x174097890 H:|-(0)-[PFImageView:0x1743e8e00] (Names: '|':UITableViewCellContentView:0x17418af80 )>",
"<NSLayoutConstraint:0x174097930 H:[PFImageView:0x1743e8e00]-(0)-| (Names: '|':UITableViewCellContentView:0x17418af80 )>",
"<NSLayoutConstraint:0x174097ac0 PFImageView:0x1743e8e00.width == PFImageView:0x1743e8e00.height>",
"<NSLayoutConstraint:0x174097b60 V:[UIImageView:0x1743e9000(30)]>",
"<NSLayoutConstraint:0x174092ed0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x17418af80(375)]>",
"<NSLayoutConstraint:0x174092f20 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x17418af80(44)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x174097b60 V:[UIImageView:0x1743e9000(30)]>
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 actually solved the problem changing the priority from the bottom of the image constrain to 750. Thanks for the help.