I have a tableview with a custom cell, where inside it I have a textview.
For this cell I determinate its hight with the size of text and it's ok.
I work in autolayout, so for my cell I use two constraints to expand the textview for all space cell in this way
I can say that it work fine and my textview expand itself for all cell space.
In the view controller I have a control to check when the text (the string) is empty. When it is empty I return 0 for the cell hight.
But in this case when I return 0 and text_view is empty I have a crash but I don't know how to solve.
this is the message
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:0x1704864a0 V:|-(25)-[UITextView:0x15454d960] (Names: '|':UITableViewCellContentView:0x178179680 )>",
"<NSLayoutConstraint:0x1704864f0 V:[UITextView:0x15454d960]-(23)-| (Names: '|':UITableViewCellContentView:0x178179680 )>",
"<NSAutoresizingMaskLayoutConstraint:0x17889a220 h=--& v=--& V:[UITableViewCellContentView:0x178179680(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1704864f0 V:[UITextView:0x15454d960]-(23)-| (Names: '|':UITableViewCellContentView:0x178179680 )>
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.
Set TranslatesAutoresizingMaskIntoConstraints to NO of cell contentView by,
[self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
Related
I have a UITableView with a header view and a custom row. The header view height is not adjusting properly to the constrained heights of its subviews.
The header view container view has the following subviews with constrained heights:
View (this height should compute to 188 but is 128 instead)
Map: UIImage (height = 128)
View: UIView (height = 60)
The header view height should be computed at Map Height + View Height = 128 + 60 = 188 as shown in Storyboard. However running this in the simulator squishes the header view to 128 like this:
Further inspection shows the header view height is 128 and not 188 as expected:
Also the Debug area shows a constraint conflict which shows the header view height is trying to be 128 which conflicts with the heights of its subviews. As a result it squishes the map height:
2015-11-27 16:58:46.415 MyApp[3387:52799] 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:0x7fcb5acf1270 h=--& v=--& V:[UIView:0x7fcb5c246620(128)]>",
"<NSLayoutConstraint:0x7fcb5c24c440 V:[Stop Details Container]-(0)-| (Names: Stop Details Container:0x7fcb5c24c490, '|':UIView:0x7fcb5c246620 )>",
"<NSLayoutConstraint:0x7fcb5c24c6f0 V:[Map]-(0)-[Stop Details Container] (Names: Stop Details Container:0x7fcb5c24c490, Map:0x7fcb5c24aa10 )>",
"<NSLayoutConstraint:0x7fcb5c24c830 V:|-(0)-[Map] (Names: Map:0x7fcb5c24aa10, '|':UIView:0x7fcb5c246620 )>",
"<NSLayoutConstraint:0x7fcb5c24c880 V:[Map(128)] (Names: Map:0x7fcb5c24aa10 )>",
"<NSLayoutConstraint:0x7fcb5c24c8d0 V:[Stop Details Container(60)] (Names: Stop Details Container:0x7fcb5c24c490 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fcb5c24c880 V:[Map(128)] (Names: Map:0x7fcb5c24aa10 )>
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.
How can I have the header view height properly compute to the heights of its subviews?
In order to force the height of the tableViewHeader I had to manually edit the height property in my Storyboard file with a text editor and this did the trick.
This is most certainly a bug in Xcode 7.1.
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.
the debug info list belows:
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:0x170c5d50 V:[UIImageView:0x170c5ca0(87)]>",
"<NSLayoutConstraint:0x170c5f70 UIImageView:0x170c5b60.top == UIImageView:0x170c5900.top>",
"<NSLayoutConstraint:0x170c6000 UIImageView:0x170c5ca0.top == UIImageView:0x170c5b60.top + 10>",
"<NSLayoutConstraint:0x170c6030 V:[UIImageView:0x170c5ca0]-(18)-| (Names: '|':UITableViewCellContentView:0x170c5400 )>",
"<NSLayoutConstraint:0x170c60f0 V:|-(15)-[UIImageView:0x170c5900] (Names: '|':UITableViewCellContentView:0x170c5400 )>",
"<NSAutoresizingMaskLayoutConstraint:0x170c6bd0 h=--& v=--& V:[UITableViewCellContentView:0x170c5400(131)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x170c5d50 V:[UIImageView:0x170c5ca0(87)]>
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.
I am doing a chat function. the outer ImageView is the background,the inner is a chat image send by user. The Inner is pinned to outer from the four side and to the contentView at bottom for autosizing the cell. At the same time ,setting its width and height constraints and the innner imageview's mode is aspectfit in storyboard. This is the conditions:
My problem is the debug log said the height cannot applyed, why ? The Height of UIImageView cannot be modified in Autolayout ? Thanks a lot, apprecating your apply.
I have a UICollectionViewCell in storyboard that has a UIImageView inside of it.
The UICollectionViewCell size is width: 189, height: 239 . The ImageView has the following constraints:
Trailing Space to cell = 31
Leading Space to cell = 31
Bottom Space to cell = 25
Top Space to cell = 31
I receive the following error when running:
2014-11-28 19:53:33.934 AppName[1585:35698] 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:0x7fa4a0d75220 H:[UIImageView:0x7fa4a0d743e0]-(31)-| (Names: '|':UIView:0x7fa4a0d73d40 )>",
"<NSLayoutConstraint:0x7fa4a0d752c0 H:|-(32)-[UIImageView:0x7fa4a0d743e0] (Names: '|':UIView:0x7fa4a0d73d40 )>",
"<NSAutoresizingMaskLayoutConstraint:0x7fa4a0d567a0 h=--& v=--& H:[UIView:0x7fa4a0d73d40(50)]>" )
Will attempt to recover by breaking constraint
NSLayoutConstraint:0x7fa4a0d75220
H:[UIImageView:0x7fa4a0d743e0]-(31)-| (Names:
'|':UIView:0x7fa4a0d73d40 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints
to catch this in the debugger. The methods in the
UIConstraintBasedLayoutDebugging category on UIView listed in
may also be helpful.
I tried changing the leading/trailing values in all kinds of ways (tried even/odd numbers) with no success. What is causing this?
This is a known bug in iOS 8 (see this post, Autoresizing issue of UICollectionViewCell contentView's frame in Storyboard prototype cell (Xcode 6, iOS 8 SDK) happens when running on iOS 7 only). The cell is the correct size that you set in the storyboard, but the cell's content view's size is staying at 50x50, which is why you get the constraint error. It can be fixed by adding this line after you create the cell in cellForItemAtIndexPath:,
cell.contentView.frame = cell.bounds
i'm currently facing this problem, i need to define a dynamic height UITableViewCell.
The red lines correspond to resizable views (will grow vertically), the blue label have 3 constraints: two for each immediate red views above (>= 8), one more with 170 and lower priority to superview.
The green one has a bottom constraint to the superview (5)
When i try to run my code, it gives me this:
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:0x19d65bb0 V:[UIView:0x19d9a9a0(5)]>",
"<NSLayoutConstraint:0x19d667d0 V:[UILabel:0x19de4180(19)]>",
"<NSLayoutConstraint:0x19d5ba70 V:[UILabel:0x19d61870(19)]>",
"<NSLayoutConstraint:0x19d36df0 V:[UILabel:0x19d36e80(19)]>",
"<NSLayoutConstraint:0x19d35d30 V:[UIView:0x19d36130(0)]>",
"<NSLayoutConstraint:0x19e7b310 V:|-(5)-[UILabel:0x19d6b520] (Names: '|':UITableViewCellContentView:0x19d97580 )>",
"<NSLayoutConstraint:0x17d0b060 V:[UILabel:0x19d6b520]-(5)-[UIView:0x19d9a9a0]>",
"<NSLayoutConstraint:0x17d0a480 V:[UIView:0x19d9a9a0]-(8)-[UILabel:0x19de4180]>",
"<NSLayoutConstraint:0x17d0c920 V:[UILabel:0x19de4180]-(8)-[UILabel:0x19d61870]>",
"<NSLayoutConstraint:0x17d0a100 V:[UILabel:0x19d61870]-(8)-[UIView:0x19d839e0]>",
"<NSLayoutConstraint:0x17d11ad0 V:[UIView:0x19d839e0]-(8)-[UILabel:0x19d36e80]>",
"<NSLayoutConstraint:0x19e742a0 V:[UILabel:0x19d36e80]-(8)-[UILabel:0x19d36770]>",
"<NSLayoutConstraint:0x19ed84a0 V:[UILabel:0x19d36770]-(8)-[UIView:0x19d36130]>",
"<NSLayoutConstraint:0x19e76410 V:[UIView:0x19d36130]-(>=8)-[UILabel:0x19d35560]>",
"<NSLayoutConstraint:0x19ed8af0 V:[UILabel:0x19d35560]-(8)-[UITextView:0x1832ba00]>",
"<NSLayoutConstraint:0x19e7abf0 V:[UITextView:0x1832ba00]-(8)-[UILabel:0x19e7d890]>",
"<NSLayoutConstraint:0x19e83d90 V:[UILabel:0x19e7d890]-(8)-[UITextView:0x18a95e00]>",
"<NSLayoutConstraint:0x19e7b520 V:[UITextView:0x18a95e00]-(5)-| (Names: '|':UITableViewCellContentView:0x19d97580 )>",
"<NSAutoresizingMaskLayoutConstraint:0x19d46fc0 h=--& v=--& V:[UITableViewCellContentView:0x19d97580(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x19d36df0 V:[UILabel:0x19d36e80(19)]>
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.
So, the question is:
What is the correct way of achieving this???
Are u using storyboard, if yes, simple go to Editor->Resolve Auto Layout Issues->Clear All Constraints In ........ Controller, and then Add Missing Constraints In ...... Controller
It will help you fix the problem of breaking contrainsts between view