The visual representation of a single row in a table view.
- iOS 2.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
UITable object is a specialized type of view that manages the content of a single table row. You use cells primarily to organize and present your app’s custom content, but
UITable provides some specific customizations to support table-related behaviors, including:
Applying a selection or highlight color to the cell.
Adding standard accessory views, such as a detail or disclosure control.
Putting the cell into an editable state.
Indenting the cell's content to create a visual hierarchy in your table.
Your app’s content occupies most of the cell’s bounds, but the cell may adjust that space to make room for other content. Cells display accessory views on the trailing edge of their content area. When you put your table into edit mode, the cell adds a delete control to the leading edge of its content area, and optionally swaps out an accessory view for a reorder control.
Every table view must have at least one type of cell for displaying content, and tables may have multiple cell types to display different types of content. Your table’s data source object handles the creation and configuration of cells immediately before they appear onscreen. For information about how to create your table’s cells, see Filling a Table with Data.
Configuring Your Cell's Content
Configure the content and layout of your cells in your storyboard file. Tables have one cell type by default, but you can add more by changing the value in the table’s Prototype Cells attribute. In addition to configuring the cell’s content, make sure you configure the following attributes:
Identifier. Use this identifier (also known as a reuse identifier) to create the cell.
Style. Choose one of the standard types or define a custom cell.
Class. Specify a
UITablesubclass with your custom behavior.
For the standard types,
UITable provides the views for displaying your content. All you have to do is assign values to the
image properties of your cell. The following illustration shows how the values you supply are positioned within the cell’s content area. If you do not supply an image for your cell, the cell distributes the extra space to the other content views.
For information about how to customize the appearance of your cells, see Configuring the Cells for Your Table.