Reputation: 6690
I need to hide a cell if a condition does not exist. Just setting cell.isHidden does not work, so the only other option I could find was setting the hightForRowAt to 0. This visually works fine but triggers a console warning: How can I hide the cell without triggering this warning all the time?
[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:0x282346080 UIView:0x104dbdb40.centerY == UITableViewCellContentView:0x104d22140.centerY (active)>",
"<NSLayoutConstraint:0x2823460d0 V:|-(11)-[UIView:0x104dbdb40] (active, names: '|':UITableViewCellContentView:0x104d22140 )>",
"<NSLayoutConstraint:0x282370320 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x104d22140.height == 0 (active)>"
)
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
var rowHeight: CGFloat = 200
switch indexPath.section {
case 0:
switch indexPath.row {
case 0:
rowHeight = 125
case 1:
rowHeight = 97
case 2:
if let workoutLocations = Metadata.workoutLocations {
if workoutLocations.count > 0 {
// rowHeight = 200
rowHeight = 220
} else {
return 0
}
} else { return 0}
case 3:
rowHeight = 446
case 4:
rowHeight = 302
case 5:
rowHeight = 302
case 6:
rowHeight = 162
case 7:
rowHeight = 192
default: ()
}
default: ()
}
return rowHeight
}
Upvotes: 1
Views: 134
Reputation: 77486
I'm assuming you have the UI elements in your cell constrained to the cell's contentView
? If so...
Select the element that has a Bottom constraint to the bottom of the content view, and change that constraint's priority:
Upvotes: 2