Difference between revisions of "iOS Table"
From Xojo Documentation
(Created page with "__TOC__ A Table is used to display lists of data. Tables can display information in sections, can have "accessories" to indicate that more information is available. Each row o...")
|Line 94:||Line 94:|
== Data Source ==
== Data Source ==
== See Also ==
== See Also ==
Revision as of 14:48, 8 February 2019
A Table is used to display lists of data. Tables can display information in sections, can have "accessories" to indicate that more information is available. Each row of a Table can display images and up to 2 lines of text. In addition you can customize the rows of a table to show pretty much whatever you want.
Below is a list of commonly used events, properties and methods. Refer to iOSTable in the Language Reference for the complete list.
- Called when the Detail accessory for a row is tapped.
- Called when a row is selected. You are provided the section and row that was tapped.
- Use this event to set up any row actions that are available for the row.
- Called when the user initiates a "pull-to-refresh" action.
- Called when a row action has been selected.
- Indicates the editing style for the row when the table is put into edit mode.
- Enable usage of the "pull-to-refresh" action for the table.
- Use this configure a Table to gets its data from a data source class rather than populating it using the methods.
- Indicates the table is currently in edit mode.
- Indicates how the table is displayed. There are two choices: Plain and Grouped.
- The number of sections in the Table. Use this in conjunction with the various methods to get row counts and other information about the table.
- A boolean that indicates if the Table is visible when your app runs.
- Adds new rows to the end or inserts rows at a specific position of the table.
- Add new sections to the end or inserts sections at a specific position of the table.
- Creates new cells (of type iOSTableCellData) to display in the table.
- Creates new custom cells that are made using iOSCustomTableCell.
- Reloads all the data in the table, just the data for a specific section or a single row.
- Removes all rows in the table, a single row in a section or an entire section.
- The count of rows in the specified section.
- Returns an instance of iOSTableCellData that contains all the information about a row in a section.
- Gets or sets the title of a section.
When working with a Table, you will need to manage its rows. The class iOSTableCellData contains information about a row in a table. To populate a table manually, you can create instances of iOSTableCellData (using iOSTable.CreateCell), set its properties and then add it to the Table. Or you can add rows using just a subset of values manually.
Use the RowData method to get the iOSTableCellData for a specific row, which you can then use or modify to change what is displayed.
Below are commonly used properties. Refer to iOSTableCellData in the Language Reference for the complete list.
- The type of (optional) accessory to display for the row. This uses the AccessoryTypes enumeration to choose the type of accessory: None, Disclosure, Detail, Checkmark.
- The Detail Text is smaller text that displays below the main text for the row.
- When an image is specified, it appears in front of the row Text.
- The Tag is an Auto that can be used to store any useful, related information about the cell for retrieval later (such as a primary key to a database or an instance of a class containing additional information).
- The main text that is displayed for the cell row.
Although you can directly add rows to a Table using the AddRow methods, this is only practical for when there are a small number of rows. When you have 50 or more rows in the table you should consider using a Data Source to provide the data for the table to display. This makes much better use of the resources available on iOS.
iOSTableDataSource is an Interface that you implement on a class that will provide the data to the Table. The table is then populated by the class so you do not have to use the Add/Insert methods.
These are the methods of the interface that have to be implemented in a class: RowCount
- Returns the number of the rows in the specified section.
- This method is used to create the iOSTableCellData for the specified section and row.
- Returns the total number of sections.
- Returns the title for the specified section.