Class
iOSTable
Warning
This item was deprecated in version 2020r2. Please use iOSMobileTable as a replacement.
Description
An iOSTable is used for displaying a list of data.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
constraint As iOSLayoutConstraint |
|||
child As MobileControl |
|||
index As Integer |
|||
text As String = "", detail As String = "", image As Picture = Nil, accessory As iOSTableCellData.AccessoryTypes = iOSTableCellData |
|||
controlClass As Introspection |
|||
section As Integer |
|||
constraint As iOSLayoutConstraint |
|||
child As MobileControl |
|||
section As Integer |
|||
section As Integer |
|||
section As Integer, row As Integer, animated As Boolean = True, position As iOSTable = ScrollPositions |
|||
value As Color |
Events
Name |
Parameters |
Returns |
---|---|---|
Enumerations
iOSTable.Formats
Formats
Indicates the formatting of the table. Used by the Format property. You can set this value using the Format property in the Inspector. (Plain, Grouped)
Enum |
Description |
---|---|
Plain |
A plain table consists of just the rows and section headings. This is the default. |
Grouped |
A grouped table has the section headings displayed outside of the table in visually distinct sections. |
iOSTable.RowEditingStyles
RowEditingStyles
The styles available for when a row is being edited. Set the style for specific rows in the RowEditingStyle event handler. (None, Delete, Insert)
Enum |
Description |
---|---|
None |
The row will have no editing control shown. |
Delete |
The row will have the deletion editing style, indicated with a red minus sign. |
Insert |
The row will have the insertion editing style, indicated with a green plus sign. This is the default for editable rows. |
iOSTable.ScrollPositions
ScrollPositions
Indicates the position of the table after scrolling to the section/row. Used by the ScrollToRow method. (None, Top, Middle, Bottom)
Enum |
Description |
---|---|
None |
Scrolls the row to be visible. No action is performed if the row is already fully visible. This is the default. |
Top |
Scrolls table so that the row is displayed at the top of the table. |
Middle |
Scrolls table so that the row is displayed in the middle of the table. |
Bottom |
Scrolls table so that the row is displayed at the bottom of the table. |
Property descriptions
iOSTable.AccessibilityHint
AccessibilityHint As Text
The accessibility hint is a longer description that is read aloud when VoiceOver is enabled.
Me.AccessibilityHint = "Click to calculate the value and display the next view."
iOSTable.AccessibilityLabel
AccessibilityLabel As Text
The accessibility label of of a control is a short name that is read aloud when VoiceOver is enabled.
Me.AccessibilityLabel = "Calculate the value."
iOSTable.AllowRefresh
AllowRefresh As Boolean
Enables iOS pull-to-refresh feature when True. When the user initiates the pull-to-refresh action, the Refreshed event is called. When done refreshing data, call the EndRefresh method.
iOSTable.DataSource
DataSource As iOSTableDataSource
The data to display in the table.
For data sets that are large, a data source allows you to efficiently provide rows without the memory cost of having an iOSTableCell in memory at all times for every single one of them.
DataSource is a weak reference so you need to make sure your data source instance does not go out of scope. The easiest way to ensure this is to make it a property of your iOSView.
iOSTable.EditingEnabled
EditingEnabled As Boolean
Determines if the table is currently being edited by the user. Animations are performed when this value is changed.
iOSTable.EstimatedRowHeight
EstimatedRowHeight As Integer
For use with custom table cells, this allows you to specify an estimated row height to help with the drawing of the rows and determine what needs scrolling.
With custom table cells, the table doesn't know in advance what the cells will be or how high they'll be. Using the estimated row height allows the table to determine how high its content is (and how much scrolling needs to happen) without instantiating every single cell that the table contains.
For non-custom cells, you should leave this as 0 and the framework will do the right thing. When you set the estimated row height, it's important to get it somewhat accurate (e.g. being 10% off probably won't matter, being 100% off causes bugs).
iOSTable.Format
Format As Formats
The format type for the table. This can only be specified at design-time in the Inspector. The default is Formats.Plain.
This property is read-only.
iOSTable.Height
Height As Double
The height of the control.
This property is read-only.
iOSTable.Left
Left As Double
The left position of the control.
This property is read-only.
iOSTable.Name
Name As Text
The name of the control. This can only be set in the Inspector. Use the name to refer to the control.
This property is read-only.
iOSTable.Parent
Parent As iOSControl
Indicates the control's parent object, if it has one. If there is no parent, this is Nil.
This property is read-only.
iOSTable.SectionCount
SectionCount As Integer
The count of sections in the table.
This property is read-only.
Get the number of sections in the table:
Var sections As Integer = Table1.SectionCount
iOSTable.Top
Top As Double
The top position of the control.
This property is read-only.
iOSTable.Visible
Visible As Boolean
Indicates whether the control is visible.
Make a button invisible:
Button1.Visible = False
iOSTable.Width
Width As Double
The width of the control.
This property is read-only.
Method descriptions
iOSTable.AddConstraint
AddConstraint(constraint As iOSLayoutConstraint)
Adds a constraint to the control. This constraint is used by child controls that have been added to this control.
iOSTable.AddControl
AddControl(child As MobileControl)
Adds a child control to the control.
iOSTable.Control
Control(index As Integer) As MobileControl
Gets the child control at the specified index.
iOSTable.ControlCount
ControlCount As Integer
The number of child controls in the control.
iOSTable.CreateCell
CreateCell(text As String = "", detail As String = "", image As Picture = Nil, accessory As iOSTableCellData.AccessoryTypes = iOSTableCellData) As MobileTableCellData
Creates a standard table cell, optionally pre-populating its properties with the specified arguments.
Use this method in place of the MobileTableCellData Constructor that was available in versions prior to 2016r2.
Create a new cell and add it to a table:
Table1.AddSection("") ' No section will appear
Var cell As iOSTableCellData
cell = Table1.CreateCell("Red Sox", "MLB", redSoxLogo, iOSTableCellData.AccessoryTypes.Detail)
Table1.AddRow(0, cell)
iOSTable.CreateCustomCell
CreateCustomCell(controlClass As Introspection) As MobileTableCellData
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.
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 iOSTableCellData = 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 iOSTableCellData = Table1.CreateCustomCell(GetTypeInfo(MyTableCell))
Var container As MyTableCell = MyTableCell(cell.Control)
container.NameLabel.Text = "Some Text"
Table1.AddRow(0, cell)
iOSTable.EndRefresh
EndRefresh
Call this method when you have finished updating data (in the Refreshed event) to close the pull-to-refresh UI.
iOSTable.Handle
Handle As Ptr
The handle is used to get a reference to the control for interfacing directly with the iOS API.
iOSTable.InsertRow
InsertRow(section As Integer, index As Integer)
Inserts the rowText for the section at the row index.
iOSTable.InsertRow
InsertRow(section As Integer, index As Integer, rowText As String)
Inserts the rowText for the section at the row index.
When you insert the row using this version of the method, its value is fetched from the DataSource. This method only works when the table has a DataSource specified.
Inserts a row at the beginning of the table, retrieving its value from the specified DataSource:
Table1.InsertRow(0, 0)
Inserts a row in the first section:
Var cell As New iOSTableCellData
cell.Text = "Hello"
Table1.InsertRow(0, 0, cell)
Inserts a row in the first position of the Table:
Table1.InsertRow(0, 0, "First Row")
iOSTable.Invalidate
Invalidate
Marks the control so that it will be redrawn during the next event loop.
Call Invalidate to force a Canvas to redraw itself:
Canvas1.Invalidate
iOSTable.ReloadData
ReloadData
Reloads all the table data from the DataSource.
It is faster to only reload the specific data that need to be refreshed, so consider using ReloadDataInSection or ReloadRow instead.
iOSTable.ReloadDataInSection
ReloadDataInSection(section As Integer)
Reloads the table data for the section.
Use this method to reload a section after changes have been made to its data (either from a DataSource or by changing the RowData).
Reload all the data in section from the related DataSource:
Table1.ReloadDataInSection(0)
iOSTable.ReloadRow
ReloadRow(section As Integer, row As Integer)
Reloads the table data for the section and row.
Use this method to reload a single cell row after changes have been made to its data (either from a DataSource or by changing the RowData).
In the Action event handler, reload the cell row after changing its AccessoryType:
Var cell As iOSTableCellData = Me.RowData(section, row)
cell.AccessoryType = iOSTableCellData.AccessoryTypes.Checkmark
Me.ReloadRow(section, row)
iOSTable.RemoveAll
RemoveAll
Removes all rows from the table.
Remove all rows:
Table1.RemoveAll
iOSTable.RemoveConstraint
RemoveConstraint(constraint As iOSLayoutConstraint)
Removes a constraint from the control.
iOSTable.RemoveControl
RemoveControl(child As MobileControl)
Removes the control from the control.
iOSTable.RemoveRow
RemoveRow(section As Integer, row As Integer)
Removes the row from the section.
Removes row 4 from section 0:
Table1.RemoveRow(0, 4)
iOSTable.RemoveSection
RemoveSection(section As Integer)
Removes the section from the table (and all its rows).
Remove section 0 and all the rows it contains:
Table1.RemoveSection(0)
iOSTable.RowCount
RowCount(section As Integer) As Integer
The count of rows in a section.
Get the counts of rows in section 0:
Var rowCount As Integer
rowCount = Table1.RowCount(0)
iOSTable.RowData
RowData(section As Integer, row As Integer) As MobileTableCellData
Returns the cell data for the section and row.
You can use this method to get at the cell data to change its contents. After changing the contents, call ReloadRow to display the new information.
Warning
An OutOfBoundsException will be raised if section and/or row does not exist.
Get all the cell data for the first row in the table and change its text:
Var cell As iOSTableCellData
cell = Table1.RowData(0, 0)
cell.Text = "Changed"
Table1.ReloadRow(0, 0)
iOSTable.ScrollToRow
ScrollToRow(section As Integer, row As Integer, animated As Boolean = True, position As iOSTable = ScrollPositions)
Scrolls the table so that the requested row is visible. The row's position when scrolling is finished is controlled by the position parameter.
Scroll to section 2, row 10:
myTable.ScrollToRow(2, 10)
myTable.ScrollToRow(2, 10, True, iOSTable.ScrollPositions.Middle)
iOSTable.SetTintColor
SetTintColor(value As Color)
Changes a control's tint color. This varies by control and for some controls may not do anything. For example, with an MobileTextField this changes the cursor color.
Event descriptions
iOSTable.AccessoryAction
AccessoryAction(section As Integer, row As Integer)
Called when the accessory (currently only Detail) for a row is tapped.
Get the row's cell data when the accessory it tapped:
Var cell As iOSTableCellData = Me.RowData(section, row)
iOSTable.Action
Action(section As Integer, row As Integer)
Called when a row has been selected.
Get the selected row:
Var selectedCell As iOSTableCellData = Me.RowData(section, row)
iOSTable.ActionsForRow
ActionsForRow(section As Integer, row As Integer)
Use this event to specify the actions that can be performed for the given section/row.
Returns an array of iOSTableRowActions that will be available for the section/row.
Multiple actions are supported. Add each action to the array that is returned from the event.
Row actions only work for tables that use iOSTableDataSourceEditing and where its RowIsEditable method returns True.
Adds two actions to every row in the table:
Var actions(1) As iOSTableRowAction
' Create the More button
actions(0) = New iOSTableRowAction(iOSTableRowAction.Styles.Normal, "More...", "More")
' Create the Delete button
actions(1) = New iOSTableRowAction(iOSTableRowAction.Styles.Destructive, "Delete", "Delete")
Return actions
iOSTable.Close
Close
Called when the control is removed from its container, such as a view.
iOSTable.Open
Open
Called after the control is created. This is where you typically put initialization code.
Set label text in Open event:
Me.Text = "Hello"
iOSTable.Refreshed
Refreshed
Called when AllowRefresh is True and the user has "pulled" to refresh the table.
Do or call you code to refresh the data here. Call the EndRefresh method when finished to close the pull-to-refresh UI.
iOSTable.RowAction
RowAction(section As Integer, row As Integer, actionTag As Variant)
A row action has been selected by the user.
Use the actionTag parameter to identify the action that was used.
Row actions only work for tables that use iOSTableDataSourceEditing and where its RowIsEditable method returns True.
Check the actionTag parameter:
Select actionTag
Case "More"
' ... show more info
Case "Delete"
' ... delete something
End Select
iOSTable.RowEditingStyle
RowEditingStyle(section As Integer, row As Integer)
Allows the table to indicate what the editing style should be for a row.
This is invoked if all of the following are met: * The table is being edited (IsEditing = True). * The table is using a custom data source with iOSTableDataSource. * The custom data source implements iOSTableDataSourceEditing interface. * The custom data source returns True from RowIsEditable for the section and row.
If this event is not implemented the default value is RowEditingStyles.Delete.
Notes
An iOSTable has only a single column of cells so by default it can only show one column of data. Use MobileTableCustomCell to create your own cells with your own cell layout. This allows you to have a cell with its own controls or even multiple columns.
A table can have data added to it in one of two ways: manually or from a data source. Some methods only work with data that was added manually, some methods only work with data added using a data source. If you are adding many rows (100+), you should instead use an iOSMobileTableDataSource for better performance and reduced memory usage.
A table must have at least one section (0-based). If there is only one section, then the section title does not appear in the table.
Sample code
Add five rows to a table:
' Simple usage
Table1.AddSection("")
For i As Integer = 0 To 4
Table1.AddRow(0, "Row " + i.ToText)
Next
Compatibility
iOS projects on the iOS operating system.
See also
MobileControl parent class; MobileTableCustomCell control; MobileTableCellData, iOSMobileTableRowAction classes; iOSMobileTableDataSource, iOSMobileTableDataSourceEditing, iOSMobileTableDataSourceReordering interfaces