# Changing iosTable Row Height after it is created

**URL:** <https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376>\
**Category:** iOS\
**Created:** [October 31, 2020, 5:53pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376 "2020-10-31T17:53:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_O\_Brien](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_o_brien/32/452_2.png) [@Chris\_O\_Brien](https://forum.xojo.com/u/Chris_O_Brien)\
**Post date:** [October 31, 2020, 5:53pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/1 "2020-10-31T17:53:00Z")

</div>

Hi

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

Chris

---

<div class="post-metadata">

**Author:** ![Art\_Gorski](https://forum.xojo.com/user_avatar/forum.xojo.com/art_gorski/32/704_2.png) [@Art\_Gorski](https://forum.xojo.com/u/Art_Gorski)\
**Post date:** [October 31, 2020, 6:17pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/2 "2020-10-31T18:17:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chris\_O\_Brien](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_o_brien/32/452_2.png) [@Chris\_O\_Brien](https://forum.xojo.com/u/Chris_O_Brien)\
**Post date:** [October 31, 2020, 6:34pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/3 "2020-10-31T18:34:37Z")

</div>

> [@Art\_Gorski](#):
>
> Projects/iOS/Controls/Table/CustomCellDynamicHeight

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

---

<div class="post-metadata">

**Author:** ![Art\_Gorski](https://forum.xojo.com/user_avatar/forum.xojo.com/art_gorski/32/704_2.png) [@Art\_Gorski](https://forum.xojo.com/u/Art_Gorski)\
**Post date:** [October 31, 2020, 6:57pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/4 "2020-10-31T18:57:00Z")

</div>

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
Next

If t <> "" Then
  customCell.AltNameLabel.Visible = True
  t = t.Left(t.Length -1) 'Remove last endofline
  customCell.AltNamesDataLabel.Text = t
Else
  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

customCell.AddConstraint(bottomConstraint)

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

Return cell
```

---

<div class="post-metadata">

**Author:** ![Chris\_O\_Brien](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_o_brien/32/452_2.png) [@Chris\_O\_Brien](https://forum.xojo.com/u/Chris_O_Brien)\
**Post date:** [November 1, 2020, 8:00am UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/5 "2020-11-01T08:00:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Art\_Gorski](https://forum.xojo.com/user_avatar/forum.xojo.com/art_gorski/32/704_2.png) [@Art\_Gorski](https://forum.xojo.com/u/Art_Gorski)\
**Post date:** [November 1, 2020, 6:42pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/6 "2020-11-01T18:42:42Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Chris\_O\_Brien](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_o_brien/32/452_2.png) [@Chris\_O\_Brien](https://forum.xojo.com/u/Chris_O_Brien)\
**Post date:** [November 1, 2020, 6:56pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/7 "2020-11-01T18:56:17Z")

</div>

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 🙂

Thanks again

---

<div class="post-metadata">

**Author:** ![Chris\_O\_Brien](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_o_brien/32/452_2.png) [@Chris\_O\_Brien](https://forum.xojo.com/u/Chris_O_Brien)\
**Post date:** [November 4, 2020, 12:08pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/8 "2020-11-04T12:08:06Z")

</div>

Worked a charm Art, thanks again 🙂

---

<div class="post-metadata">

**Author:** ![Art\_Gorski](https://forum.xojo.com/user_avatar/forum.xojo.com/art_gorski/32/704_2.png) [@Art\_Gorski](https://forum.xojo.com/u/Art_Gorski)\
**Post date:** [November 4, 2020, 6:23pm UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/9 "2020-11-04T18:23:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [May 6, 2021, 6:23am UTC](https://forum.xojo.com/t/changing-iostable-row-height-after-it-is-created/58376/10 "2021-05-06T06:23:20Z")

</div>

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