What does it mean
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:0x7f871d1303b0 H: [UIButton:0x7f871d197640(30)]>",
"<NSLayoutConstraint:0x7f871d1a1c40 H:[UIButton:0x7f871d196960'LB'(30)]>",
"<NSLayoutConstraint:0x7f871d1a4570 H:[UIView:0x7f871d196d60]-(100.8)-| (Names: '|':UIView:0x7f871ac66870 )>",
"<NSLayoutConstraint:0x7f871d1a5200 H:|-(0)-[UIView:0x7f871d196d60] (Names: '|':UIView:0x7f871ac66870 )>",
"<NSLayoutConstraint:0x7f871d19c5f0 H:[UIView:0x7f871ac66870]-(0)-| (Names: '|':UIView:0x7f871d199d70 )>",
"<NSLayoutConstraint:0x7f871d19c640 H:|-(20)-[UIView:0x7f871ac66870] (Names: '|':UIView:0x7f871d199d70 )>",
"<NSLayoutConstraint:0x7f871d1a8ca0 H:|-(0)-[UIView:0x7f871d199d70] (Names: '|':UIView:0x7f871d199c00 )>",
"<NSLayoutConstraint:0x7f871d1a8d40 UIView:0x7f871d19c820.width == UIView:0x7f871d199d70.width>",
"<NSLayoutConstraint:0x7f871d1a8de0 H:[UIView:0x7f871d199d70]-(10)-[UIView:0x7f871d19c820]>",
"<NSLayoutConstraint:0x7f871d1a8e80 H:[UIView:0x7f871d19c820]-(10)-[UIView:0x7f871d1a7000]>",
"<NSLayoutConstraint:0x7f871d1a8f20 UIView:0x7f871d1a7000.width == UIView:0x7f871d199d70.width>",
"<NSLayoutConstraint:0x7f871d1a8f70 H:[UIView:0x7f871d1a7000]-(0)-| (Names: '|':UIView:0x7f871d199c00 )>",
"<NSLayoutConstraint:0x7f871d1a9450 H:|-(15)-[UIButton:0x7f871d197640] (Names: '|':UIView:0x7f871d19b130 )>",
"<NSLayoutConstraint:0x7f871d1a9540 H:[UIButton:0x7f871d197640]-(10)-[UIView:0x7f871d199c00]>",
"<NSLayoutConstraint:0x7f871d1a95e0 H:[UIView:0x7f871d199c00]-(10)-[UIButton:0x7f871d196960'LB']>",
"<NSLayoutConstraint:0x7f871d1a96d0 H:[UIButton:0x7f871d196960'LB']-(10)-| (Names: '|':UIView:0x7f871d19b130 )>",
"<NSLayoutConstraint:0x7f871d1aa340 H:[UIView:0x7f871d19b130]-(0)-| (Names: '|':UIView:0x7f871d19afc0 )>",
"<NSLayoutConstraint:0x7f871d1aa390 H:|-(0)-[UIView:0x7f871d19b130] (Names: '|':UIView:0x7f871d19afc0 )>",
"<NSLayoutConstraint:0x7f871d1b7230 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f871d19afc0(320)]>"
)
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 <UIKit/UIView.h> may also be helpful.
That means you are giving more constraints than required so it's creates ambiguity.
For example if you have one label having height of 30.
Now you give constraints like top,leading and trailing with constant of 20 and fixed height of 30. that means your label always maintain space of 20 of each side from top,left and right and always keep height of 30.
That's fine.
now if you add one another constraint say fixed width with constant 50 that means label's width should be 50.
Now if your app running on 4 inch device then your screen width is 320.
So, if label maintain width of 50 then can't maintain left and right spacing of 20 and if it maintains spacing of 20 then can't maintain width.
This situation is called ambiguity.
This was an example for understanding.
Your constraints making this kind of ambiguity somewhere, so check twice and remove unnecessary or additional constraints.
hope this will help :)
Probably, something is wrong with constraints for UIView:0x7f871d199d70: as I see, you and/or XCode added offsets and also width.
Related
I have app with enabled rotation for iPad (iPhone version is rotation-free). In my design, within storyboard, I have this hierarchy: UIView - UIScrollView - UIView. All "views" are set to have full width of the screen. Second UIView has class set to MyView, which is a class with an external xib file. Storyboard and xib are both created in a portrait mode.
Now for the problem.
If I run the app in the landscape mode, all is loaded OK. If I rotate
app after that, all is OK.
If I run the app in the portrait mode, the design "breaks". The entire content is thiner (so there is about 100+ px gap between the end of MyView and the end of the screen). If I rotate app, the design remains broken but correctly "enlarged". The gap is still of the same size. During the first launch, I got the following error in debugger:
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:0x1545b7800 h=-&- v=-&- UIView:0x1546a8cb0.width == ScrollableContentView:0x154575da0.width - 232>",
"<NSLayoutConstraint:0x15458dd80 H:[UIActivityIndicatorView:0x1546afa60]-(370)-| (Names: '|':UIView:0x1546ab840 )>",
"<NSLayoutConstraint:0x15458ddd0 H:|-(361)-[UIActivityIndicatorView:0x1546afa60] (Names: '|':UIView:0x1546ab840 )>",
"<NSLayoutConstraint:0x1546c7080 H:[UIView:0x1546ab840]-(0)-| (Names: '|':UIView:0x1546a8cb0 )>",
"<NSLayoutConstraint:0x1546c7120 H:|-(0)-[UIView:0x1546ab840] (Names: '|':UIView:0x1546a8cb0 )>",
"<NSLayoutConstraint:0x154579710 H:|-(0)-[ScrollableContentView:0x154575da0] (Names: '|':UIScrollView:0x15504c000 )>",
"<NSLayoutConstraint:0x154686ef0 UIScrollView:0x15504c000.centerX == ScrollableContentView:0x154575da0.centerX>",
"<NSLayoutConstraint:0x154697cc0 H:[UIScrollView:0x15504c000]-(0)-| (Names: '|':UIView:0x154547b80 )>",
"<NSLayoutConstraint:0x154697d10 H:|-(0)-[UIScrollView:0x15504c000] (Names: '|':UIView:0x154547b80 )>",
"<NSLayoutConstraint:0x15463b8c0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x154547b80(768)]>"
)
Will attempt to recover by breaking constraint
No matter what I do, I am unable to remove this problem. Even If I deleted almost every constraint I have still the same issue.
You should look if you don't have any auto layout warnings in your storyboard or xib file (yellow/red dot beside your controller name in document outline).
If you don't have any, do you set your constraints when adding your xib view ?
Have you think about content hugging priority or content compression resistance priority ?
Trying to get autolayout to work so that cell resizing can be achieved.
This is how my storyboard looks like:
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.
2016-06-01 14:05:24.587 BrandSpace[4968:1387945] 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:0x1258c32a0 H:[LikeButton:0x1258c2d80'Like'(46)]>",
"<NSLayoutConstraint:0x1258c3830 H:[UILabel:0x1258c35d0'1'(121)]>",
"<NSLayoutConstraint:0x1258c4290 H:|-(8)-[LikeButton:0x1258c2d80'Like'] (Names: '|':UIView:0x1258bf6f0 )>",
"<NSLayoutConstraint:0x1258c4330 H:[LikeButton:0x1258c2d80'Like']-(387)-[UILabel:0x1258c35d0'1']>",
"<NSLayoutConstraint:0x1258c4380 H:[UILabel:0x1258c35d0'1']-(8)-| (Names: '|':UIView:0x1258bf6f0 )>",
"<NSLayoutConstraint:0x1258c47c0 H:[UIView:0x1258bf6f0]-(15)-| (Names: '|':UITableViewCellContentView:0x1258c1a50 )>",
"<NSLayoutConstraint:0x1258c4810 H:|-(15)-[UIView:0x1258bf6f0] (Names: '|':UITableViewCellContentView:0x1258c1a50 )>",
"<NSLayoutConstraint:0x1247fb850 'fittingSizeHTarget' H:[UITableViewCellContentView:0x1258c1a50(375)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1258c3830 H:[UILabel:0x1258c35d0'1'(121)]>
OK, a really simple version of this that breaks...
Create a UIView in a nib.
Add an imageView to it. Give the image view a constraint for an Aspect Ratio of 1:1.
Now add constraints from the image view to the edge of the view. (0 size to pin it to the edges).
Now add the view as a UITableView tableHeaderView.
When you run the application on different devices it will break the constraints and remove the aspect ratio constraint. I don't want this, I want it to change the height of the view to be equal to the width.
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:0x7fad01efbbe0 UIImageView:0x7fad047209b0.width == UIImageView:0x7fad047209b0.height>",
"<NSLayoutConstraint:0x7fad04703630 H:[UIImageView:0x7fad047209b0]-(0)-| (Names: '|':VenueHeaderView:0x7fad047204c0 )>",
"<NSLayoutConstraint:0x7fad04703680 V:|-(0)-[UIImageView:0x7fad047209b0] (Names: '|':VenueHeaderView:0x7fad047204c0 )>",
"<NSLayoutConstraint:0x7fad04703740 V:[UIImageView:0x7fad047209b0]-(0)-| (Names: '|':VenueHeaderView:0x7fad047204c0 )>",
"<NSLayoutConstraint:0x7fad04703790 H:|-(0)-[UIImageView:0x7fad047209b0] (Names: '|':VenueHeaderView:0x7fad047204c0 )>",
"<NSLayoutConstraint:0x7fad0429bcf0 'UIView-Encapsulated-Layout-Height' V:[VenueHeaderView:0x7fad047204c0(300)]>",
"<NSLayoutConstraint:0x7fad0429bca0 'UIView-Encapsulated-Layout-Width' H:[VenueHeaderView:0x7fad047204c0(375)]>" )
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7fad01efbbe0 UIImageView:0x7fad047209b0.width == UIImageView:0x7fad047209b0.height>
It seems that there are constraints UIView-Encapsulated-Layout-Height being added to the superview. But these are added with the wrong value. It should recalculate these based on the internal constraints of the header view.
I am trying to fix these errors I keep getting when running my app.
I have a UITableView that uses prototype cells and I keep getting these errors despite having no errors listed in Xcode Storyboard for constraint problems.
Not sure how to read most of these errors so was hoping someone could assist me?
Background UIImageView that should stretch entire cell width/height:
(
"<NSLayoutConstraint:0x174086c20 UIImageView:0x1741e7100.width == 2.5*UIImageView:0x1741e7100.height>",
"<NSLayoutConstraint:0x174087530 H:|-(0)-[UIImageView:0x1741e7100] (Names: '|':UITableViewCellContentView:0x174181e10 )>",
"<NSLayoutConstraint:0x1740875d0 V:[UIImageView:0x1741e7100]-(0)-| (Names: '|':UITableViewCellContentView:0x174181e10 )>",
"<NSLayoutConstraint:0x174087620 H:[UIImageView:0x1741e7100]-(0)-| (Names: '|':UITableViewCellContentView:0x174181e10 )>",
"<NSLayoutConstraint:0x174087670 V:|-(0)-[UIImageView:0x1741e7100] (Names: '|':UITableViewCellContentView:0x174181e10 )>",
"<NSLayoutConstraint:0x170088890 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x174181e10(375)]>",
"<NSLayoutConstraint:0x1700888e0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x174181e10(160)]>"
)
UIImageViews (5) that are suppose to be matching width/height, centered on 3rd UIImageView in cell and equal distances apart from each other (when rotated to landscape, these items stay centered and the distance from left/right on first/last cell just increases):
(
"<NSLayoutConstraint:0x174086e00 Bobblehead_TV.BobbleheadImageView:0x100715ff0.width == 0.5*Bobblehead_TV.BobbleheadImageView:0x100715ff0.height>",
"<NSLayoutConstraint:0x1740873a0 Bobblehead_TV.BobbleheadImageView:0x100715ff0.width == Bobblehead_TV.BobbleheadImageView:0x1007180e0.width>",
"<NSLayoutConstraint:0x1740873f0 H:|-(0)-[Bobblehead_TV.BobbleheadImageView:0x100715ff0] (Names: '|':UITableViewCellContentView:0x174181e10 )>",
"<NSLayoutConstraint:0x174087490 Bobblehead_TV.BobbleheadImageView:0x100715ff0.top == UIImageView:0x1741e7100.top>",
"<NSLayoutConstraint:0x1740874e0 Bobblehead_TV.BobbleheadImageView:0x100715ff0.bottom == UIImageView:0x1741e7100.bottom>",
"<NSLayoutConstraint:0x1740875d0 V:[UIImageView:0x1741e7100]-(0)-| (Names: '|':UITableViewCellContentView:0x174181e10 )>",
"<NSLayoutConstraint:0x174087670 V:|-(0)-[UIImageView:0x1741e7100] (Names: '|':UITableViewCellContentView:0x174181e10 )>",
"<NSLayoutConstraint:0x174087710 Bobblehead_TV.BobbleheadImageView:0x1007207d0.width == Bobblehead_TV.BobbleheadImageView:0x1007180e0.width>",
"<NSLayoutConstraint:0x174087800 H:[Bobblehead_TV.BobbleheadImageView:0x100715ff0]-(>=0)-[Bobblehead_TV.BobbleheadImageView:0x1007207d0]>",
"<NSLayoutConstraint:0x174087850 UITableViewCellContentView:0x174181e10.centerX == Bobblehead_TV.BobbleheadImageView:0x1007180e0.centerX>",
"<NSLayoutConstraint:0x1740878a0 H:[Bobblehead_TV.BobbleheadImageView:0x1007207d0]-(>=0)-[Bobblehead_TV.BobbleheadImageView:0x1007180e0]>",
"<NSLayoutConstraint:0x170088890 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x174181e10(375)]>",
"<NSLayoutConstraint:0x1700888e0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x174181e10(160)]>"
)
Background UIImageView that should stretch entire cell width/height:
You want the image view to stretch the entire cell, but you have a rule UIImageView:0x1741e7100.width == 2.5*UIImageView:0x1741e7100.height that locks the aspect ratio at 1:2.5. You need to remove this rule.
UIImageViews (5) that are suppose to be matching width/height, centered on 3rd UIImageView in cell and equal distances apart from each other (when rotated to landscape, these items stay centered and the distance from left/right on first/last cell just increases):
This one is much more complex, but I will hazard a guess that it's the same aspect ratio problem. This time is Bobblehead_TV.BobbleheadImageView:0x100715ff0.width == 0.5*Bobblehead_TV.BobbleheadImageView:0x100715ff0.height which locks the aspect ratio at 1:0.5.
My Friend,
Reasons could be
1: You have insufficient constraints to satisfy the layout. or
2: You have added more than the required constraints.
As a result of which layout is ambiguous. It is confused and so warning .
My opinion is to recheck all your constraints. And provide minimal constraints but be specific.
Thanks
I have a problem with autolayout contraints on my iPad project, when I rotate my device I have this error :
2013-06-03 13:16:24.969 PDFViewer[7534:907] 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:0x1f5525e0 H:[UIScrollView:0x1f551910]-(970)-| (Names: '|':UIView:0x1f547740 )>",
"<NSLayoutConstraint:0x1f5525a0 H:|-(0)-[UIScrollView:0x1f551910] (Names: '|':UIView:0x1f547740 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1f562520 h=--- v=--- H:[UIWindow:0x1f543890(768)]>",
"<NSAutoresizingMaskLayoutConstraint:0x1f560af0 h=-&- v=-&- UIView:0x1f547740.width == UIWindow:0x1f543890.width>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1f5525e0 H:[UIScrollView:0x1f551910]-(970)-| (Names: '|':UIView:0x1f547740 )>
Ok, some constraints are contentious but I don't set any constraint by myself, they are all set automatically in Interface Builder and I can't remove them. What I want is pretty simple, a scrollview, with fixed width and 100% height, and a collection view, with remaining width and 100% height.
Autolayout makes me crazy, any idea ?
Edit : Here are my constraints defined in IB
Error was caused by an automatic constraint, more precisely this one :
"<NSLayoutConstraint:0x1f5525e0 H:[UIScrollView:0x1f551910]-(970)-| (Names: '|':UIView:0x1f547740 )>",
As it is added by IB you can't delete it, so for ignoring it I have set the priority to 1.