table view Unable to simultaneously satisfy constraints - ios

what I'm doing here? I'm trying to build an Instagram clone and in my home view controller that what should posts show up. I make navigation with a table view and that table view has 2 cell with the different identifier. cell number 1 it's a header that brings data from users table to my username label and profile image. and cell number 2 its for posts its should bring post data like image and caption. I use firebase database. the problem is my layout is a not show like what i want and its give this error:
2017-12-31 00:00:31.920010+0300 Instgram Clone[2165:463944] [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:0x60000029af40 UIImageView:0x7fdc8765e940.height == 375 (active)>",
"<NSLayoutConstraint:0x604000284ba0 UIButton:0x7fdc874433e0.height == 30 (active)>",
"<NSLayoutConstraint:0x604000285460 V:|-(0)-[UIImageView:0x7fdc8765e940] (active, names: '|':UITableViewCellContentView:0x7fdc8765e110 )>",
"<NSLayoutConstraint:0x6040002854b0 V:[UIImageView:0x7fdc8765e940]-(7)-[UIStackView:0x7fdc87442fd0] (active)>",
"<NSLayoutConstraint:0x6040002855a0 V:[UIStackView:0x7fdc87442fd0]-(7)-[UIView:0x7fdc87441230] (active)>",
"<NSLayoutConstraint:0x604000285640 V:[UIView:0x7fdc87441230]-(7)-[UIButton:0x7fdc87441410'\U2665\Ufe0e 15 Likes'] (active)>",
"<NSLayoutConstraint:0x604000285690 V:[UIButton:0x7fdc87441410'\U2665\Ufe0e 15 Likes']-(NSSpace(8))-[UILabel:0x7fdc87442870'What a. Great day'] (active)>",
"<NSLayoutConstraint:0x6040002857d0 V:[UILabel:0x7fdc87442870'What a. Great day']-(NSSpace(8))-[UIButton:0x7fdc87442550'Be the first one share a ...'] (active)>",
"<NSLayoutConstraint:0x6040002858c0 UITableViewCellContentView:0x7fdc8765e110.bottomMargin == UILabel:0x7fdc87442b50'2 Day ago'.bottom + 12 (active)>",
"<NSLayoutConstraint:0x604000285910 V:[UIButton:0x7fdc87442550'Be the first one share a ...']-(NSSpace(8))-[UILabel:0x7fdc87442b50'2 Day ago'] (active)>",
"<NSLayoutConstraint:0x60000029c9d0 'UISV-canvas-connection' UIStackView:0x7fdc87442fd0.top == _UILayoutSpacer:0x6000001c8160'UISV-alignment-spanner'.top (active)>",
"<NSLayoutConstraint:0x604000281bd0 'UISV-canvas-connection' UIStackView:0x7fdc87442fd0.centerY == UIButton:0x7fdc874433e0.centerY (active)>",
"<NSLayoutConstraint:0x60000029c840 'UISV-spanning-boundary' _UILayoutSpacer:0x6000001c8160'UISV-alignment-spanner'.top <= UIButton:0x7fdc874433e0.top (active)>",
"<NSLayoutConstraint:0x604000285cd0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fdc8765e110.height == 58.5 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x604000284ba0 UIButton:0x7fdc874433e0.height == 30 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
just for knowledge :
postcell = header of view
imagecell = the post of view
header cell constraints
post cell constraints
Continue with post cell constraints
this image to my result layout when the running app
my new error message when I fix the content view high :
2018-01-01 02:56:25.304650+0300 Instgram Clone[1217:35419] Month 13 is out of bounds
2018-01-01 02:56:25.312217+0300 Instgram Clone[1217:35419] Month 13 is out of bounds
2018-01-01 02:56:25.338368+0300 Instgram Clone[1217:35424] Month 13 is out of bounds
2018-01-01 02:56:25.343009+0300 Instgram Clone[1217:35431] Month 13 is out of bounds
2018-01-01 02:56:25.374175+0300 Instgram Clone[1217:35323] [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:0x600000483750 UIImageView:0x7fdf61548390.height == 36 (active)>",
"<NSLayoutConstraint:0x600000483d90 V:[UIImageView:0x7fdf61548390]-(8.5)-| (active, names: '|':UITableViewCellContentView:0x7fdf615481a0 )>",
"<NSLayoutConstraint:0x600000483de0 V:|-(12)-[UIImageView:0x7fdf61548390] (active, names: '|':UITableViewCellContentView:0x7fdf615481a0 )>",
"<NSLayoutConstraint:0x604000482530 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fdf615481a0.height == 57 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000483750 UIImageView:0x7fdf61548390.height == 36 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

Related

Unable to simultaneously satisfy constraints runtime error in Swift

I get this error in runtime for my ios(UIKit) application. It is coming from UITableView. The app runs without constraint errors and with the expected behavior.
I've seen other questions regarding the same error but should I leave this error as it is?
The error is partially complaining about my two UITableView which are connected through a cell(First table uses 1.6 as the aspect ratio and second view uses .55 for width/size). I'm not sure how this can be fixed since there is no problem and these views are separate.
[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:0x600001575860 UIImageView:0x7f8795f474f0.width == 1.6*UIImageView:0x7f8795f474f0.height (active)>",
"<NSLayoutConstraint:0x600001575770 V:|-(10)-[UIStackView:0x7f8795f47080] (active, names: '|':UITableViewCellContentView:0x7f8795f46b50 )>",
"<NSLayoutConstraint:0x600001575810 V:[UIStackView:0x7f8795f47080]-(10)-| (active, names: '|':UITableViewCellContentView:0x7f8795f46b50 )>",
"<NSLayoutConstraint:0x600001575950 UIImageView:0x7f8795f474f0.width == 0.55*UITableViewCellContentView:0x7f8795f46b50.width (active)>",
"<NSLayoutConstraint:0x600001573f20 'UISV-alignment' UILabel:0x7f8795f47210.bottom == UIImageView:0x7f8795f474f0.bottom (active)>",
"<NSLayoutConstraint:0x600001575ae0 'UISV-alignment' UILabel:0x7f8795f47210.top == UIImageView:0x7f8795f474f0.top (active)>",
"<NSLayoutConstraint:0x60000150cdc0 'UISV-canvas-connection' UIStackView:0x7f8795f47080.top == UILabel:0x7f8795f47210.top (active)>",
"<NSLayoutConstraint:0x60000150ce60 'UISV-canvas-connection' V:[UILabel:0x7f8795f47210]-(0)-| (active, names: '|':UIStackView:0x7f8795f47080 )>",
"<NSLayoutConstraint:0x600001575cc0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7f8795f46b50.height == 154.333 (active)>",
"<NSLayoutConstraint:0x600001575c70 'UIView-Encapsulated-Layout-Width' UITableViewCellContentView:0x7f8795f46b50.width == 390 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600001575860 UIImageView:0x7f8795f474f0.width == 1.6*UIImageView:0x7f8795f474f0.height (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.
It seems you're setting constraints to the same view twice:
"<NSLayoutConstraint:0x600001575860 UIImageView:0x7f8795f474f0.width == 1.6*UIImageView:0x7f8795f474f0.height (active)>",
"<NSLayoutConstraint:0x600001575950 UIImageView:0x7f8795f474f0.width == 0.55*UITableViewCellContentView:0x7f8795f46b50.width (active)>"

Why do I get a constraint error with UIDatePicker and static UITableView?

I'm building a form to enter data in an application, and I'm using a UITableView built only with static cells, as the fields the user needs to fill won't change. One of these fields is a date. For this field, I'm trying to use a UIDatePicker set to .compact, so it shows the date in one line, and when the user taps the date a modal calendar will be displayed (new iOS 14 behavior).
The problem is that every time I tap the date (in the simulator), I get the constraint error detailed below:
[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.
(
"<_UISystemBaselineConstraint:0x60000343e3a0 H:[_UIDatePickerLinkedLabel:0x7fb3a0d79f10]-(NSLayoutAnchorConstraintSpace(8))-[UILayoutGuide:0x600002e207e0''] (active)>",
"<_UISystemBaselineConstraint:0x60000343e8a0 H:[UILayoutGuide:0x600002e207e0'']-(>=NSLayoutAnchorConstraintSpace(8))-[_UIDatePickerTouchOutsetButton:0x7fb3a0d7acc0] (active)>",
"<NSLayoutConstraint:0x6000034373e0 UILabel:0x7fb3a0d7a0d0.trailing <= _UIDatePickerLinkedLabel:0x7fb3a0d79f10.trailing (active)>",
"<NSLayoutConstraint:0x6000034372a0 H:|-(0)-[UILabel:0x7fb3a0d7a0d0] (active, names: '|':_UIDatePickerLinkedLabel:0x7fb3a0d79f10 )>",
"<NSLayoutConstraint:0x60000343e210 _UIDatePickerLinkedLabel:0x7fb3a0d79f10.leading == UILayoutGuide:0x600002e208c0'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x60000343e2b0 H:[_UIDatePickerTouchOutsetButton:0x7fb3a0d7acc0]-(28)-[_UIDatePickerTouchOutsetButton:0x7fb3a0d7afc0] (active)>",
"<NSLayoutConstraint:0x60000343e120 _UIDatePickerTouchOutsetButton:0x7fb3a0d7afc0.trailing == UILayoutGuide:0x600002e208c0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600003441fe0 UILayoutGuide:0x600002e207e0''.width == UIImageView:0x7fb3a0d7aaf0.width (active)>",
"<NSLayoutConstraint:0x600003429950 _UIDatePickerCalendarContentStackView:0x7fb3a0d76c60.width <= _UIDatePickerCalendarView:0x7fb3a0d9e2a0.width (active)>",
"<NSLayoutConstraint:0x600003449f40 H:|-(0)-[_UIDatePickerCalendarView:0x7fb3a0d9e2a0] (active, names: '|':UIDatePicker:0x7fb3a0d23900 )>",
"<NSLayoutConstraint:0x600003449ef0 _UIDatePickerCalendarView:0x7fb3a0d9e2a0.trailing == UIDatePicker:0x7fb3a0d23900.trailing (active)>",
"<NSLayoutConstraint:0x600003420190 H:|-(8)-[UIDatePicker:0x7fb3a0d23900] (active, names: '|':UIView:0x7fb3a0e78db0 )>",
"<NSLayoutConstraint:0x6000034201e0 UIDatePicker:0x7fb3a0d23900.trailing == UIView:0x7fb3a0e78db0.trailing - 8 (active)>",
"<NSLayoutConstraint:0x600003425ea0 'UISV-canvas-connection' _UIDatePickerCalendarContentStackView:0x7fb3a0d76c60.leading == _UIDatePickerCalendarHeaderView:0x7fb3a0d76df0.leading (active)>",
"<NSLayoutConstraint:0x600003425f40 'UISV-canvas-connection' H:[_UIDatePickerCalendarHeaderView:0x7fb3a0d76df0]-(0)-| (active, names: '|':_UIDatePickerCalendarContentStackView:0x7fb3a0d76c60 )>",
"<NSLayoutConstraint:0x600003442940 'UIView-Encapsulated-Layout-Width' UIView:0x7fb3a0e78db0.width == 0 (active)>",
"<NSLayoutConstraint:0x6000034378e0 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x600002e208c0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIDatePickerCalendarHeaderView:0x7fb3a0d76df0 )>",
"<NSLayoutConstraint:0x600003437980 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600002e208c0'UIViewLayoutMarginsGuide']-(8)-|(LTR) (active, names: '|':_UIDatePickerCalendarHeaderView:0x7fb3a0d76df0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000034373e0 UILabel:0x7fb3a0d7a0d0.trailing <= _UIDatePickerLinkedLabel:0x7fb3a0d79f10.trailing (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.
I've tried to set constraints to the date picker in the static cell, but the error persists. I've also tried leaving the picker without any constraints, without luck.
Any ideas about what could be the issue here? I'm probably doing some basic mistake, but I couldn't identify it.
Environment:
Swift 5
iOS 14.x
Looking at your error message UILabel:0x7fb3a0d7a0d0.trailing <= _UIDatePickerLinkedLabel:0x7fb3a0d79f10.trailing (active)>
I figured out that your Cells label constraint are added to Picker view.
Remove all picker constraints from Cell and make it relative to controllers view.

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

ios view resized in storyboard but does not show during runtime

i have a view with subview and tableview in it. please see picture below. i increased the height of 'CheckoutNTotal' view in storyboard and adjusted the x,y co-ordinates for 'Tbl Orders' accordingly. But when I run it in simulator, the 'CheckoutNTotal' view does not show full height. what could be going on. I have attached storyboard view, runtime view as well. Appreciate any help.
EDIT 1:
thanks for replying. did you mean 'View Debugging' under 'Debug' menu? that didn't show anything. but i do see these nasty constraints messages in console:
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.
(
"<_UILayoutSupportConstraint:0x600003a6c780 _UILayoutGuide:0x7f9269f2edd0.height == 64 (active)>",
"<_UILayoutSupportConstraint:0x600003a6c460 V:|-(0)-[_UILayoutGuide:0x7f9269f2edd0] (active, names: '|':UIView:0x7f9269f2e4f0 )>",
"<_UILayoutSupportConstraint:0x600003a6c960 _UILayoutGuide:0x7f9269f2f160.height == 49 (active)>",
"<_UILayoutSupportConstraint:0x600003a6c7d0 _UILayoutGuide:0x7f9269f2f160.bottom == UIView:0x7f9269f2e4f0.bottom (active)>",
"<NSLayoutConstraint:0x600003a6d8b0 V:|-(84)-[UIStepper:0x7f926b550320] (active, names: '|':UIView:0x7f9269f2e660 )>",
"<NSLayoutConstraint:0x600003a6da90 UILabel:0x7f9269f29c60'Tip'.centerY == UIStepper:0x7f926b550320.centerY (active)>",
"<NSLayoutConstraint:0x600003a6dbd0 V:[UILabel:0x7f9269f29c60'Tip']-(123)-| (active, names: '|':UIView:0x7f9269f2e660 )>",
"<NSLayoutConstraint:0x600003a6e260 V:[_UILayoutGuide:0x7f9269f2edd0]-(0)-[UIView:0x7f9269f2e660] (active)>",
"<NSLayoutConstraint:0x600003a6e490 V:[UIView:0x7f9269f2e660]-(342)-[_UILayoutGuide:0x7f9269f2f160] (active)>",
"<NSLayoutConstraint:0x600003a36990 'UIView-Encapsulated-Layout-Height' UIView:0x7f9269f2e4f0.height == 568 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003a6da90 UILabel:0x7f9269f29c60'Tip'.centerY == UIStepper:0x7f926b550320.centerY (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.
so i guess i need to fix them.

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?

Resources