I get this error:
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:0x1600aec0 V:[UIView:0x102021d0]-(0)-| (Names: '|':UIView:0x1600a980 )>",
"<NSLayoutConstraint:0x1600ae80 V:|-(494)-[UIView:0x102021d0] (Names: '|':UIView:0x1600a980 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1600e8a0 h=-&- v=-&- UIView:0x1600a980.height == UIWindow:0x9e0ea30.height>",
"<NSAutoresizingMaskLayoutConstraint:0x9e2d130 h=--- v=--- V:[UIWindow:0x9e0ea30(480)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1600aec0 V:[UIView:0x102021d0]-(0)-| (Names: '|':UIView:0x1600a980 )>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in
<UIKit/UIView.h> may also be helpful.
the view that generates this error has 4 constrains for left/right/top/bottom and I can not delete any of them.
I have tried:
[View setTranslatesAutoresizingMaskIntoConstraints:NO];
with no result.
do you have any idea how to fix this?
Thank you!
The problem is in the vertical layout.
<NSAutoresizingMaskLayoutConstraint:0x9e2d130 h=--- v=--- V:[UIWindow:0x9e0ea30(480)]>
Autoresizing mask for a window. Fixed margins and size. You can't change this.
<NSAutoresizingMaskLayoutConstraint:0x1600e8a0 h=-&- v=-&- UIView:0x1600a980.height == UIWindow:0x9e0ea30.height>
Autoresing mask (fixed margins, resizable content). Probably the view of your controller. The height is 480 (set to be equal to the size of the window). Nothing to fix here.
<NSLayoutConstraint:0x1600aec0 V:[UIView:0x102021d0]-(0)-| (Names: '|':UIView:0x1600a980 )>
<NSLayoutConstraint:0x1600ae80 V:|-(494)-[UIView:0x102021d0] (Names: '|':UIView:0x1600a980 )>
You can notice that both constraints are doing something with the same view ([UIView:0x102021d0]) and have the same second view as a parameter (UIView:0x1600a980). The second view is our controller's view.
The two constraints define distances from edges of the second view. The first defines bottom (0). The second one defines top (494). If the superview's size is 480, that means [UIView:0x102021d0] would have height equal to -14 which triggers that exception.
How to fix it? Well, change the 494 constraint to the correct value. It's possible you don't even want the "top" constraint, maybe you want a fixed height instead.
How did the problem arise? You probably created your constraints for iPhone 5 and then you tried to run the app with iPhone 4. If you change the simulated size in your xib to iPhone 4, you should see the problem immediately.
There are still views that have translatesAutoresizingMaskIntoConstraints set to YES, apparently, otherwise you wouldn't be getting that message. It's probably the superview of the view that's giving you problems. Make sure that it also doesn't translate its autoresizing masks to constraints.
Related
I'm using autolayout with UITableViewCell and got following errors.
How can I fix it?
2020-09-15 11:42:13.104796+0900 heart-to-heart[14602:1800620] [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:0x6000022eb890 UIImageView:0x7fdd1f01efc0.height == 50 (active)>",
"<NSLayoutConstraint:0x6000022c7480 V:|-(16)-[UIImageView:0x7fdd1f01efc0] (active, names: '|':UITableViewCellContentView:0x7fdd1f01eb00 )>",
"<NSLayoutConstraint:0x6000022c74d0 V:[UIImageView:0x7fdd1f01efc0]-(16)-| (active, names: '|':UITableViewCellContentView:0x7fdd1f01eb00 )>",
"<NSLayoutConstraint:0x6000022c1d10 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fdd1f01eb00.height == 82.3333 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000022eb890 UIImageView:0x7fdd1f01efc0.height == 50 (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.
If you are setting the height for the ImageView then no need to set the bottom constraint and even top constraint. Remove both bottom and top constraint and add the constraint to centerY i.e. center vertically the image view to the container.
The reason why you are getting this issue is because it is ambiguous as which constraint to satisfy whether the height constraint of the Image view or top/ bottom constraint.
The app allows users to post images/follow others etc.
So it works fine but i get the following warnings:
(I know some has to do with AutoLayout constraints but how do i know which is causing the problems?)
2015-07-05 17:19:37.701 Pixym[1271:72192] CUICatalog: Invalid asset name supplied:
2015-07-05 17:19:37.702 Pixym[1271:72192] Could not load the "" image referenced from a nib in the bundle with identifier "HP.Pixym"
2015-07-05 17:19:37.705 Pixym[1271:72192] 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:0x7fa83b822a40 H:[UIImageView:0x7fa83b8529a0(300)],
NSLayoutConstraint:0x7fa83b85ccb0 H:[UIImageView:0x7fa83b8529a0]-(10)-| (Names: '|':UITableViewCellContentView:0x7fa83b871ff0 ),
NSLayoutConstraint:0x7fa83b8643d0 H:|-(10)-[UIImageView:0x7fa83b8529a0] (Names: '|':UITableViewCellContentView:0x7fa83b871ff0 ),
NSLayoutConstraint:0x7fa83b80ab00 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x7fa83b871ff0(375)])
Will attempt to recover by breaking constraint
NSLayoutConstraint:0x7fa83b822a40 H:[UIImageView:0x7fa83b8529a0(300)]
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.
Any help will be appreciated.
From the constraints, it seems you have an imageView with a width of 300 and a left and right padding of 10. That would work fine on iPhone 5(where the screen width is 320) but it will crash on iPhone 6/ 6 Plus because there the width is bigger.
What you need to do, is figure out how would you want the image to look like on all screens. Is the 10 pixels padding more important than the width or you would like it to always have a width of 300?
If you want the width, remove the other 2 constraints and add a center horizontal in container constraint for the image.
In the other case, just remove the width constraints and all should work.
Good luck!
I would like to adjust a cell dynamically to show all text which I have provided to a label inside of this particular cell. I have a custom cell and it cuts me the text and shows 3 dots at the end.
While trying this in viewdidload:
tableView.estimatedRowHeight = tableView.rowHeight
tableView.rowHeight = UITableViewAutomaticDimension
a) it destroys me the whole layout
b) shows me this error msg:
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:0x7faa6a5ab2f0 H:[UIImageView:0x7faa6a5ad100(135)]>",
"<NSLayoutConstraint:0x7faa6a5b9af0 UIImageView:0x7faa6a5ad100.leading == UITableViewCellContentView:0x7faa6a5acba0.leadingMargin>",
"<NSLayoutConstraint:0x7faa6a5b9c80 UILabel:0x7faa6a5b3f00'Mercedes-Benz G500 4x4\U00b2 s...'.trailing == UITableViewCellContentView:0x7faa6a5acba0.trailingMargin>",
"<NSLayoutConstraint:0x7faa6a5b9d20 H:[UIImageView:0x7faa6a5ad100]-(8)-[UILabel:0x7faa6a5b3f00'Mercedes-Benz G500 4x4\U00b2 s...']>",
"<NSLayoutConstraint:0x7faa6a5c09c0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x7faa6a5acba0(34)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7faa6a5ab2f0 H:[UIImageView:0x7faa6a5ad100(135)]>
Is there a way to check out from this error message whats the matter here?
This question already has answers here:
Xcode 4.4 constraint errors
(2 answers)
Closed 9 years ago.
I'm making full-frame subview, ( subview's frame = superview's bound )
I made expansion like following
[self addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:#"H:|-0-[subview]-0-|"
options:NSLayoutFormatDirectionLeadingToTrailing
metrics:nil
views:NSDictionaryOfVariableBindings(subview)]];
[self addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:#"V:|-0-[subview]-0-|"
options:NSLayoutFormatDirectionLeadingToTrailing
metrics:nil
views:NSDictionaryOfVariableBindings(subview)]];
But run time error occus, shown the following error.
"<NSAutoresizingMaskLayoutConstraint:0x1001bb700 h=--& v=--& H:[IUView:0x10015dcc0(960)]>",
"<NSLayoutConstraint:0x1001911d0 H:|-(0)-[IUBGView:0x1001783f0] (Names: '|':IUView:0x10015dcc0 )>",
"<NSLayoutConstraint:0x1001910e0 H:[IUBGView:0x1001783f0]-(0)-| (Names: '|':IUView:0x10015dcc0 )>",
"<NSLayoutConstraint:0x10017bbf0 H:|-(0)-[NSImageView:0x100160050] (Names: '|':IUBGView:0x1001783f0 )>",
"<NSLayoutConstraint:0x10015d7f0 H:[NSImageView:0x100160050]-(0)-| (Names: '|':IUBGView:0x1001783f0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1001a6a80 h=--& v=--& H:[NSImageView:0x100160050(0)]>"
Will attempt to recover by breaking constraint
Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, break on objc_exception_throw to catch this in the debugger.
Can you explain what I missed?
It appears that you're not turning of the 'translatesAutoresizingMaskInotConstraints' feature of the views you've created by hand.
someView.translatesAutoresizingMaskIntoConstraints = NO;
If you don't set that to NO then iOS converts the springs-and-struts (e.g. auto resizing mask) settings to constraints. Those constraints are conflicting with the ones you're making with the visual format language.
Anytime you see the class 'NSAutoresizingMaskLayoutConstraint' in the constaints error output then you can be sure you haven't turned off translates.
Good practice is that on every view you create programmatically, you also turn of translates.
I have a scence with a bunch of labels and buttons. When you tap on a button a view slides up from the bottom with controls in it, a kind of keyboard so to say. It "looks" like this:
-----------------------------
| |
| [Button 1] [ Slider 1 ] |
| |
| [Button 2] [ Slider 2 ] |
| |
-----------------------------
This "keyboard" is created at the very beginning when the view loads and the animation is done switching its heigth from 0 to its instrinsic content size. This escene only supports landscape mode and it took me quite a while to keep the "keyboard" on the view when the device rotates 180 degrees.
The problem I see pops up with either of the two following situations:
The device rotates 180 degrees.
The "keyboard" is called.
This problem as follows:
Unable to simultaneously satisfy constraints...
.
.
.
.
(
"<NSLayoutConstraint:0x718c6c0 UIButton:0x717e0d0.centerY == UISlider:0x717d9d0.centerY>",
"<NSLayoutConstraint:0x7190a00 UIButton:0x717e0d0.centerY == UISlider:0x717d9d0.centerY>"
)
The error log gives me this error twice, once for each set of button-slider.
What I think is weird is that the conflicting constraints are exactly the same. I thought I did some copy-paste mistake and added the same constraint twice, but it's not the case.
I'm guessing it has something to do with updateViewConstraints being called upon rotation and also whe I perform the animation, but I cannot see why only these constraints are affected since there are some more in this "keyboard" view.
All and all, this Autolayout is beign quite more difficult than Apples whants to claim. In my opinion, of course.
Any ideas?
EDIT: the constrains are set all in code using mainly the visual language format. The constrains of the controls inside the "keyboard" are added into the "keyboard" view which is the normal thing to do, I believe.
Just to try it out, I changed the problematic constraints and, instead to adding them to the "keyboard" subview, I added them to the self.view ("keyboard" superview). All the sudden, no more errors are shown.
Despite of that, I'd really like some discussion on the matter because I still don't know what's wrong and I just had a lucky shot. I'd really like to undestand it.
The fact that the conflicting constraints are exactly the same is in fact the error. With Auto Layout, you can't have a constraint twice. That will generate the error you see above.
Definitely, you have added the constraint twice. You can see this from the memory addresses. You have two different NSLayoutConstraint instances, 0x718c6c0 and 0x7190a00. However, the instances each refers to are both the same. That being that the vertical center centerY of your UIButton instance 0x717e0d0 should be in the middle of the UISlider 0x717d9d0.
Possibly your updateConstraints method has been called and you haven't checked to see if a constraint already exists before adding it again.
I don't know if this may help you but I just used this tutorial for setting up constraints to buttons and labels in my app