Changing iosTable Row Height after it is created


I am trying to change the height of a row after it is created in an iOSTable (to show/hide more items in a custom cell), but I can’t seem to manage it and I can’t find any examples in Xojo or on the web.

Has anyone any experience in doing this, if it’s possible?

Thanks in advance


Look at Example Projects/iOS/Controls/Table/CustomCellDynamicHeight

I’ve got this to work. Note that you shouldn’t put a Layout Constraint on cell height in the iDE. So it will display badly in the IDE.

Hi Art. Thanks for responding - When you say you got it to work, di you develop further from this example to to achieve it on the fly? This was one of the first examples I went to, but unless I’m missing something, this is only adjusting the height on creation and not after the row is created. I know what you mean about using constraints - Controls draw over other rows.

Thanks again. Chris

Yes, it adjusts on the fly:

In the RowData of the datasource I have an AltNamesDataLabel label at the bottom of the custom cell that can grow in length as a I add items followed by an EndofLine.

Var cell As iOSTableCellData = table.CreateCustomCell(GetTypeInfo(TMSectorTableCell))
Var customCell As TMSectorTableCell = TMSectorTableCell(cell.Control)
Var t As Text = ""

customCell.SectorNameLabel.Text = TMSectorsSubSet(row).Name
customCell.AbbreviationLabel.Text = TMSectorsSubSet(row).Abbreviation
customCell.TagLabel.Text = TMSectorsSubSet(row).Tag

If System.Version >= "13" Then
  customCell.SFSymbolsIcon.Image = iOSImage.SystemImage("list.bullet",0,iosimage.SystemImageWeights.Regular,SymbolColorGroup,Nil)
End If

For Each altname As Text In TMSectorsSubSet(row).AltNames
  t = t + altname + Text.EndOfLine

If t <> "" Then
  customCell.AltNameLabel.Visible = True
  t = t.Left(t.Length -1) 'Remove last endofline
  customCell.AltNamesDataLabel.Text = t
  customCell.AltNameLabel.Visible = False
  customCell.AltNamesDataLabel.Text = ""
End If

Var bottomConstraint As New iOSLayoutConstraint( _
customCell, _                              ' firstItem
iOSLayoutConstraint.AttributeTypes.Bottom, _ ' firstAttribute
iOSLayoutConstraint.RelationTypes.Equal, _  ' relation
customCell.AltNamesDataLabel, _                            ' secondItem
iOSLayoutConstraint.AttributeTypes.Bottom, _ ' secondAttribute
1.0, _                                      ' multiplier
8, _           ' gap
1000)                                       ' highest priority


If TMSectorsSubSet(row).Name = TMSectorName Then
  cell.AccessoryType = iOSTableCellData.AccessoryTypes.Checkmark
  cell.AccessoryType = iOSTableCellData.AccessoryTypes.None
End If

Return cell

Thanks very much for your time Art. I think this is effectively still doing the same as the original, where each cell height is determined at instantiation. For example, what I’m trying to do, to use your project is only show the teams, then have a “Show Alternatives” button in each cell, which would expand the cell height of the row clicked, revealing the alternatives, click it again and the row collapses to the original size.

I’m not sure if it’s possible with Xojo. You can see it with the Apple’s Calendar when you click on a date, the DatePicker is revealed

NOW I understand what you want to do. If the button updates the datasource and then you reload the table, wouldn’t that do it?

Thanks Art. Sounds like it would do it alright - I’ll try it. It was probably an obvious answer to you - still learning for me :slight_smile:

Thanks again

Worked a charm Art, thanks again :slight_smile:

You’re welcome. I’ve gotten a lot of good help in this forum over the years and like to give back when I can.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.