iOSMobileTable.CreateCustomCell

From Xojo Documentation

Method

iOSMobileTable.CreateCustomCell(controlClass As Introspection.TypeInfo) As MobileTableCellData

Supported on Mobile.

Creates or reuses a table cell that uses a custom control that is based on MobileTableCustomCell. If there is no view to reuse, the cell's control will be instantiated from the passed type information.

Parameters

Parameter Description
controlClass The type of the MobileTableCustomCell subclass that will be displayed in the custom cell.

Notes

This is also usable by applications that use AddRow instead of data sources with the caveat that no reuse is possible. This is not recommended for performance reasons and users needing more than a screen's worth of rows should use a data source. If the number of rows with custom controls exceeds a certain threshold the framework will log a message in the debugger to advise users of the situation.

The following exceptions can be raised:

Exception Description
NilObjectException If controlClass is Nil.
InvalidArgumentException
  • If controlClass is not referring to a class or if the class has no default constructor to invoke.
  • If controlClass does not inherit from MobileUIControl.

Sample Code

MyTableCell is a subclass of MobileTableCustomCell that contains several controls, including a label called NameLabel. This code adds MyTableCell as a custom cell in the table and is in the RowData method of class that implements iOSMobileTableDataSource:

Var cell As iOSMobileTableCellData = table.CreateCustomCell(GetTypeInfo(MyTableCell))
Var container As MyTableCell = MyTableCell(cell.Control)
container.NameLabel.Text = "Some Text"
Return cell

This code directly adds MyTableCell as a custom cell to a table using the AddRow method:

Table1.AddSection("")
Var cell As MobileTableCellData = Table1.CreateCustomCell(GetTypeInfo(MyTableCell))
Var container As MyTableCell = MyTableCell(cell.Control)
container.NameLabel.Text = "Some Text"
Table1.AddRow(0, cell)

See Also

MobileTableCustomCell class.