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?
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.
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
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