Class

iOSMobileTable


Description

An iOSMobileTable is used for displaying a list of data.

Methods

Name

Parameters

Returns

Shared

AddConstraint

constraint As iOSLayoutConstraint

AddControl

child As MobileUIControl

AddRow

section As Integer, value As MobileTableCellData

section As Integer, value As String

value As String

AddRowAt

section As Integer, index As Integer

section As Integer, index As Integer, value As MobileTableCellData

section As Integer, index As Integer, value As String

AddSection

title As String = ""

title As String = ""

Integer

AddSectionAt

index As Integer

index As Integer, title As String

ClearFocus

Constructor

format As Formats

ControlAt

index As Integer

MobileUIControl

Controls

Iterable

CreateCell

value As String = "", detail As String = "", image As Picture = Nil, accessory As AccessoryTypes = AccessoryTypes.None

MobileTableCellData

CreateCustomCell

controlClass As Introspection.TypeInfo

MobileTableCellData

EndRefresh

Handle

Ptr

Refresh

ReloadDataInSection

section As Integer

ReloadDataSource

ReloadRow

section As Integer, row As Integer

RemoveAllRows

RemoveConstraint

constraint As iOSLayoutConstraint

RemoveControl

child As MobileUIControl

RemoveRowAt

section As Integer, row As Integer

RemoveSectionAt

section As Integer

RowCellData

row As Integer

MobileTableCellData

section As Integer, row As Integer

MobileTableCellData

RowCount

section As Integer

Integer

ScrollToRow

row As Integer, animated As Boolean = True, position As ScrollPositions = ScrollPositions.None

section As Integer, row As Integer, animated As Boolean = True, position As ScrollPositions = ScrollPositions.None

SearchControllerHandle

Ptr

SectionTitleAt

section As Integer

String

section As Integer, Assigns value As String

SelectRow

section As Integer, row As Integer

SetFocus

Enumerations

iOSMobileTable.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, InsetGrouped)

Name

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.

InsetGrouped

A grouped table where the grouped sections are inset with rounded corners.

iOSMobileTable.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)

Name

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.

iOSMobileTable.ScrollPositions

ScrollPositions

Indicates the position of the table after scrolling to the section/row. Used by the ScrollToRow method. (None, Top, Middle, Bottom)

Name

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


iOSMobileTable.AccessibilityHint

AccessibilityHint As String

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 screen."

iOSMobileTable.AccessibilityLabel

AccessibilityLabel As String

The accessibility label of of a control is a short name that is read aloud when VoiceOver is enabled.

Me.AccessibilityLabel = "Calculate the value."

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


iOSMobileTable.AllowSearch

AllowSearch As Boolean

Adds a search field to the table. Pull down on the table at runtime to display the search field.


iOSMobileTable.ControlCount

ControlCount As Integer

The number of child controls in the control.


iOSMobileTable.DataSource

DataSource As iOSMobileTableDataSource

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 MobileTableCellData 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 MobileScreen.


iOSMobileTable.EditingEnabled

EditingEnabled As Boolean

Determines if the table is currently being edited by the user. Animations are performed when this value is changed.


iOSMobileTable.Enabled

Enabled As Boolean

Indicates whether the control is enabled or disabled.

Disable the button:

Button1.Enabled = False

iOSMobileTable.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).


iOSMobileTable.Format

Format As Formats

The format type for the table. This can only be specified at design-time in the Inspector. The default is iOSMobileTable.Plain.

This property is read-only.


iOSMobileTable.Height

Height As Integer

The height of the control.

This property is read-only.


iOSMobileTable.Left

Left As Integer

The left position of the control.

This property is read-only.


iOSMobileTable.Name

Name As String

The name of the control.

This property is read-only.


iOSMobileTable.Parent

Parent As MobileUIControl

The parent (sometimes called a "Super") class of the control.

This property is read-only.


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

iOSMobileTable.SelectedRow

SelectedRow As Pair

Returns the selected section and row via a Pair.

This property is read-only.

Var selection As Pair = Table1.SelectedRow
Var section, row As Integer
section = selection.Left
row = selection.Right

iOSMobileTable.TintColor

TintColor As ColorGroup

Changes a control's tint color.

On iOS, the following controls support TintColor:

Enum

Description

ProgressBar

The area indicating the value of the control will be drawn in the TintColor.

Slider

The area indicating the value of the control will be drawn in the TintColor.

Switch

The background of the color will be drawn in the TintColor.

TextArea

The cursor and text highlight color will be drawn in the TintColor.

TextField

The cursor and text highlight color will be drawn in the TintColor.


iOSMobileTable.Top

Top As Integer

The top position of the control.

This property is read-only.


iOSMobileTable.Visible

Visible As Boolean

Indicates whether the control is visible.

Make a button invisible:

Button1.Visible = False

iOSMobileTable.Width

Width As Integer

The width of the control.

This property is read-only.

Method descriptions


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


iOSMobileTable.AddControl

AddControl(child As MobileUIControl)

Adds a child control to the control.


iOSMobileTable.AddRow

AddRow(section As Integer, value As MobileTableCellData)

Adds a new row with the value fetched from the DataSource. This method only works when the table has a DataSource specified.


iOSMobileTable.AddRow

AddRow(section As Integer, value As String)

Adds a new row with the value passed.


iOSMobileTable.AddRow

AddRow(value As String)

Adds a new row with the value passed.

There has to be at least one section before you can add rows or you will get an OutOfBoundsException. If you do not want the section to appear, you can add it with a blank title.

If you are adding many rows, you should instead use iOSMobileTableDataSource for better performance and reduced memory usage.

The following exceptions can be raised:

Exception

Description

OutOfBoundsException

When the section does not exist. At least one section must be added to the table before adding rows.

UnsupportedOperationException

When the table has a DataSource specified.

Adds five rows to a table:

Table1.AddSection("") ' No section will appear
For i As Integer = 0 To 4
  Table1.AddRow(0, "Row " + i.ToString)
Next

Adds five rows to a table using a cell:

Table1.AddSection("") ' No section will appear
Var cell As MobileTableCellData

For i As Integer = 0 To 4
  cell = Table1.CreateCell("Row " + i.ToString)
  Table1.AddRow(0, cell)
Next

iOSMobileTable.AddRowAt

AddRowAt(section As Integer, index As Integer)

Adds a new row for the section at the row index.


iOSMobileTable.AddRowAt

AddRowAt(section As Integer, index As Integer, value As MobileTableCellData)

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.


iOSMobileTable.AddRowAt

AddRowAt(section As Integer, index As Integer, value As String)

Adds a new row with the value for the section at the row index.

Adds a row at the beginning of the table, retrieving its value from the specified DataSource:

Table1.AddRowAt(0, 0)

Inserts a row in the first section:

Var cell As New MobileTableCellData
cell.Text = "Hello"
Table1.AddRowAt(0, 0, cell)

Add a row in the first position of the Table:

Table1.AddRowAt(0, 0, "First Row")

iOSMobileTable.AddSection

AddSection(title As String = "")

Adds a section, with the optional title, to the table returning the index number for the new section.


iOSMobileTable.AddSection

AddSection(title As String = "") As Integer

Adds a section, with the optional title, to the table returning the index number for the new section.

For a Plain table format, section headings appear in the table itself. Only non-blank section titles appear. If you add a section with a blank title, you cannot change the title later.

For a Group table format, the sections appear outside of the table.

Warning

If an iOSMobileTableDataSource is assigned, sections cannot be added because the iOSMobileTableDataSource is responsible for that. If you try to add a section when a DataSource has been assigned, an UnsupportedOperationException will be raised.

Add a section called "Tasks":

Table1.AddSection("Tasks")

You may want to add a section and save the returned section number so you can use it to subsequently add rows:

Var newSection As Integer = Table1.AddSection("Tasks")
Table1.AddRow(newSection, "Task 1")
Table1.AddRow(newSection, "Task 2")

iOSMobileTable.AddSectionAt

AddSectionAt(index As Integer)

Adds the section title at the specified index.


iOSMobileTable.AddSectionAt

AddSectionAt(index As Integer, title As String)

Adds the section title at the specified index.

When you insert a section using this method, its value is fetched from the DataSource. This method only works when the table has a DataSource specified. It does nothing when the table does not have a DataSource.

Adds a row in the first position of the table, retrieving its value from the specified DataSource:

Table1.AddRowAt(0)

Inserts a section at the top of the table:

Table1.AddSectionAt(0, "First!")

iOSMobileTable.ClearFocus

ClearFocus

Removes the focus from the control.

TextField1.ClearFocus

iOSMobileTable.Constructor

Constructor(format As Formats)

Note

Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.

Creates a table with the specified format.


iOSMobileTable.ControlAt

ControlAt(index As Integer) As MobileUIControl

Gets the child control at the specified index.


iOSMobileTable.Controls

Controls As Iterable

Allows you to iterate through all the controls that have been added to this control.

Important

This is supported for iOS only.


iOSMobileTable.CreateCell

CreateCell(value As String = "", detail As String = "", image As Picture = Nil, accessory As AccessoryTypes = AccessoryTypes.None) 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 MobileTableCellData
cell = Table1.CreateCell("Red Sox", "MLB", redSoxLogo, MobileTableCellData.AccessoryTypes.Detail)
Table1.AddRow(0, cell)

iOSMobileTable.CreateCustomCell

CreateCustomCell(controlClass As Introspection.TypeInfo) 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.

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.

Warning

A NilObjectException will be raised if the controlClass is Nil.

Warning

An InvalidArgumentException will be raised if the controlClass is not referring to a class, the controlClass refers to a class that has no default constructor or if the controlClass does not inherit from MobileUIControl.

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)

iOSMobileTable.EndRefresh

EndRefresh

Call this method when you have finished updating data (in the Refreshed event) to close the pull-to-refresh UI.


iOSMobileTable.Handle

Handle As Ptr

The handle to the underlying native OS control.


iOSMobileTable.Refresh

Refresh

Marks the control so that it will be redrawn during the next event loop.

Call Refresh to force a Canvas to redraw itself:

Canvas1.Refresh

iOSMobileTable.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)

iOSMobileTable.ReloadDataSource

ReloadDataSource

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.


iOSMobileTable.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 SelectionChanged event handler, reload the cell row after changing its AccessoryType:

Var cell As MobileTableCellData = Me.RowData(section, row)
cell.AccessoryType = MobileTableCellData.AccessoryTypes.Checkmark
Me.ReloadRow(section, row)

iOSMobileTable.RemoveAllRows

RemoveAllRows

Removes all rows from the table.

Remove all rows:

Table1.RemoveAllRows

iOSMobileTable.RemoveConstraint

RemoveConstraint(constraint As iOSLayoutConstraint)

Removes a constraint from the control.


iOSMobileTable.RemoveControl

RemoveControl(child As MobileUIControl)

Removes the control from the control.


iOSMobileTable.RemoveRowAt

RemoveRowAt(section As Integer, row As Integer)

Removes the row from the section.

Removes row 4 from section 0:

Table1.RemoveRowAt(0, 4)

iOSMobileTable.RemoveSectionAt

RemoveSectionAt(section As Integer)

Removes the section from the table (and all its rows).

Remove section 0 and all the rows it contains:

Table1.RemoveSectionAt(0)

iOSMobileTable.RowCellData

RowCellData(row As Integer) As MobileTableCellData

Returns the cell data for the section and row.


iOSMobileTable.RowCellData

RowCellData(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

If the section and/or row does not exist, an OutOfBoundsException will be raised.

Get all the cell data for the first row in the table and change its text:

Var cell As MobileTableCellData
cell = Table1.RowCellData(0, 0)
cell.Text = "Changed"
Table1.ReloadRow(0, 0)

iOSMobileTable.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)

iOSMobileTable.ScrollToRow

ScrollToRow(row As Integer, animated As Boolean = True, position As iOSMobileTable = ScrollPositions.None<iosmobiletable.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.


iOSMobileTable.ScrollToRow

ScrollToRow(section As Integer, row As Integer, animated As Boolean = True, position As ScrollPositions = ScrollPositions.None)

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, Table.ScrollPositions.Middle)

iOSMobileTable.SearchControllerHandle

SearchControllerHandle As Ptr

Returns a Ptr to the search controller for use with Declares.


iOSMobileTable.SectionTitleAt

SectionTitleAt(section As Integer) As String

Sets the title for the section.


iOSMobileTable.SectionTitleAt

SectionTitleAt(section As Integer, Assigns value As String)

Sets the title for the section.

You cannot change the title section that was originally given a blank title.

The following exception can be raised:

Exception

Description

OutOfBoundsException

When the section does not exist. At least one section must be added to the table before getting or setting its title.

Change the first section title:

Table1.SectionTitleAt(0) = "New Title"

Get the title of the 2nd section:

Var title As String = Table1.SectionTitleAt(1)

iOSMobileTable.SelectRow

SelectRow(section As Integer, row As Integer)

Selects the row in section/row passed.

Select the first row in the first section:

Table1.SelectRow(0,0)

iOSMobileTable.SetFocus

SetFocus

Sets the focus to the control.

TextField1.SetFocus

Event descriptions


iOSMobileTable.AccessoryPressed

AccessoryPressed(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 MobileTableCellData = Me.RowCellData(section, row)

iOSMobileTable.ApplyActionsForRow

ApplyActionsForRow(section As Integer, row As Integer) As iOSMobileTableRowAction()

Use this event to specify the actions that can be performed for the given section/row when the user swipes from right to left.

Returns an array of iOSMobileTableRowActions 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 iOSMobileTableDataSourceEditing and where its RowIsEditable method returns True.

Adds two actions to every row in the table:

Var actions(1) As iOSMobileTableRowAction
' Create the More button
actions(0) = New iOSMobileTableRowAction(iOSMobileTableRowAction.Styles.Normal, "More...", "More")
' Create the Delete button
actions(1) = New iOSMobileTableRowAction(iOSMobileTableRowAction.Styles.Destructive, "Delete", "Delete")
Return actions

iOSMobileTable.ApplyLeadingActionsForRow

ApplyLeadingActionsForRow(section As Integer, row As Integer) As iOSMobileTableRowAction()

Use this event to specify the actions that can be performed for the given section/row when the user swipes from left to right.

Returns an array of iOSMobileTableRowActions 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 iOSMobileTableDataSourceEditing and where its RowIsEditable method returns True.

Adds two actions to every row in the table:

Var actions(1) As iOSMobileTableRowAction
' Create the More button
actions(0) = New iOSMobileTableRowAction(iOSMobileTableRowAction.Styles.Normal, "More...", "More")
' Create the Delete button
actions(1) = New iOSMobileTableRowAction(iOSMobileTableRowAction.Styles.Destructive, "Delete", "Delete")
Return actions

iOSMobileTable.ApplyRowEditingStyle

ApplyRowEditingStyle(section As Integer, row As Integer) As RowEditingStyles

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

  • The custom data source implements iOSMobileTableDataSourceEditing 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.


iOSMobileTable.Closing

Closing

Called when the control's layout is closing.


iOSMobileTable.Opening

Opening

Called when the control's layout is opening.

This is where you typically put initialization code.

This example in the Opening event of a label sets its text to "Hello":

Me.Text = "Hello"

iOSMobileTable.Refreshed

Refreshed

Called when AllowRefresh is True and the user has "pulled" to refresh the table.

Do not call your code to refresh the data here. Call the EndRefresh method when finished to close the pull-to-refresh UI.


iOSMobileTable.RowActionSelected

RowActionSelected(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 iOSMobileTableDataSourceEditing and where its AllowRowEditing method returns True.

Check the actionTag parameter:

Select Case actionTag
Case "More"
  ' ... show more info
Case "Delete"
  ' ... delete something
End Select

iOSMobileTable.SearchChanged

SearchChanged(value As String)

The value of the table's search field was changed.


iOSMobileTable.SelectionChanged

SelectionChanged(section As Integer, row As Integer)

A row has been selected.

Get the selected row:

Var selectedCell As MobileTableCellData = Me.RowCellData(section, row)

Notes

An iOSMobileTable 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.ToString)
Next

Compatibility

iOS projects on the iOS operating system.