0

When my UITableViewCell rows display they're coming up with a height of 44. They definitely shouldn't be doing that. I've constrained the whole top to bottom of the path, as you can see in the warnings below about bad constraints.

Ignoring the fact it doesn't like my $ballIsSquare$ height/width constraint, I should still have a cell that is more than 44 in height. It's showing almost circular balls, meaning the height is almost 55 tall (since it's showing $ballWidth$ as 55. However, it's not showing the date label at all, which is constrained to be above the balls. Any idea what the cell is being forced to be so small?

The view controller is specifying an estimated row height of 100 for this, and the rowHeight is set to UITableViewAutomaticDimension.

I think the "UISV-alignment" and UISV-canvas-connection are the constraints from the UIStackView that's being used ($ballsBottom$ for example is referring to the balls UIStackView)

The UIView-Encapsulated-Layout-Height is the one that seems to me to be the real issue.

    "<NSLayoutConstraint:0x60400008d070 '$ballIsSquare$' DidIWin.BallView:0x7f8525a3fec0.height == DidIWin.BallView:0x7f8525a3fec0.width   (active)>",
    "<NSLayoutConstraint:0x604000091ad0 '$ballsBottom$' DidIWin.Balls:0x7f8525a3e890.bottom == UILayoutGuide:0x6040001a6c80'UIViewSafeAreaLayoutGuide'.bottom - 10   (active)>",
    "<NSLayoutConstraint:0x604000086c70 '$ballWidth$' DidIWin.BallView:0x7f8525a3fec0.width == 55   (active)>",
    "<NSLayoutConstraint:0x6040000928e0 '$largeDateBottom$' UILabel:0x7f8525a44510'10/4/17'.bottom == DidIWin.Balls:0x7f8525a3e890.top + 10   (active)>",
    "<NSLayoutConstraint:0x604000092840 '$largeDateTop$' UILabel:0x7f8525a44510'10/4/17'.top == UILayoutGuide:0x6040001a6c80'UIViewSafeAreaLayoutGuide'.top + 10   (active)>",
    "<NSLayoutConstraint:0x604000092020 'UISV-alignment' DidIWin.BallView:0x7f8525a3ead0.bottom == DidIWin.BallView:0x7f8525a3fec0.bottom   (active)>",
    "<NSLayoutConstraint:0x604000091f30 'UISV-alignment' DidIWin.BallView:0x7f8525a3ead0.top == DidIWin.BallView:0x7f8525a3fec0.top   (active)>",
    "<NSLayoutConstraint:0x60400008c670 'UISV-canvas-connection' DidIWin.Balls:0x7f8525a3e890.top == DidIWin.BallView:0x7f8525a3ead0.top   (active)>",
    "<NSLayoutConstraint:0x604000091c60 'UISV-canvas-connection' V:[DidIWin.BallView:0x7f8525a3ead0]-(0)-|   (active, names: '|':DidIWin.Balls:0x7f8525a3e890 )>",
    "<NSLayoutConstraint:0x604000091da0 'UIView-Encapsulated-Layout-Height' DidIWin.FailureDetailCell:0x7f8526047200'failure'.height == 44   (active)>",
    "<NSLayoutConstraint:0x604000091940 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x6040001a6c80'UIViewSafeAreaLayoutGuide']-(0)-|   (active, names: '|':DidIWin.FailureDetailCell:0x7f8526047200'failure' )>",
    "<NSLayoutConstraint:0x6040000918a0 'UIViewSafeAreaLayoutGuide-top' V:|-(0)-[UILayoutGuide:0x6040001a6c80'UIViewSafeAreaLayoutGuide']   (active, names: '|':DidIWin.FailureDetailCell:0x7f8526047200'failure' )>"

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60400008d070 '$ballIsSquare$' DidIWin.BallView:0x7f8525a3fec0.height == DidIWin.BallView:0x7f8525a3fec0.width   (active)>
Gargoyle
  • 7,401
  • 10
  • 55
  • 99

1 Answers1

-1
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
    if(indexPath.section == 0){
        return 50
    }else{
        return 120
    }
}

Add this delegate method in your view controller

or you can use

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 
       return UITableViewAutomaticDimension
}

for automatic dimension

Sushin PS
  • 110
  • 4
  • No, that's not what I want. It's not a static sized cell. It's dynamic sized, based on the constraints that are set. – Gargoyle Nov 07 '17 at 06:50
  • The delegate method you show is not useful. The height method isn't really needed as a delegate. it's already set that way on the table itself. Note also that I stated I had that set already in the third paragraph of my question. The question is asking WHY am I getting the height forced to 44 based on the constraints shown. – Gargoyle Nov 07 '17 at 07:01