UITableViewDelegate
Methods for managing selections, configuring section headers and footers, deleting and reordering cells, and performing other actions in a table view.
Declaration
@MainActor protocol UITableViewDelegate : UIScrollViewDelegateOverview
Use the methods of this protocol to manage the following features:
Create and manage custom header and footer views.
Specify custom heights for rows, headers, and footers.
Provide height estimates for better scrolling support.
Indent row content.
Respond to row selections.
Respond to swipes and other actions in table rows.
Support editing the table’s content.
The table view specifies rows and sections using IndexPath. For information about how to interpret row and section indexes, see Specify the location of rows and sections.
Topics
Configuring rows for the table view
tableView(_:willDisplay:forRowAt:)tableView(_:indentationLevelForRowAt:)tableView(_:shouldSpringLoadRowAt:with:)
Responding to row selections
Handling row selection in a table viewSelecting multiple items with a two-finger pan gesturetableView(_:willSelectRowAt:)tableView(_:didSelectRowAt:)tableView(_:willDeselectRowAt:)tableView(_:didDeselectRowAt:)tableView(_:shouldBeginMultipleSelectionInteractionAt:)tableView(_:didBeginMultipleSelectionInteractionAt:)tableViewDidEndMultipleSelectionInteraction(_:)
Providing custom header and footer views
tableView(_:viewForHeaderInSection:)tableView(_:viewForFooterInSection:)tableView(_:willDisplayHeaderView:forSection:)tableView(_:willDisplayFooterView:forSection:)
Providing header, footer, and row heights
tableView(_:heightForRowAt:)tableView(_:heightForHeaderInSection:)tableView(_:heightForFooterInSection:)automaticDimension
Estimating heights for the table’s content
tableView(_:estimatedHeightForRowAt:)tableView(_:estimatedHeightForHeaderInSection:)tableView(_:estimatedHeightForFooterInSection:)
Managing accessory views
Managing context menus
Adding context menus in your apptableView(_:contextMenuConfigurationForRowAt:point:)tableView(_:previewForDismissingContextMenuWithConfiguration:)tableView(_:previewForHighlightingContextMenuWithConfiguration:)tableView(_:willDisplayContextMenu:animator:)tableView(_:willEndContextMenuInteraction:animator:)tableView(_:willPerformPreviewActionForMenuWith:animator:)
Responding to row actions
tableView(_:leadingSwipeActionsConfigurationForRowAt:)tableView(_:trailingSwipeActionsConfigurationForRowAt:)tableView(_:shouldShowMenuForRowAt:)tableView(_:canPerformAction:forRowAt:withSender:)tableView(_:performAction:forRowAt:withSender:)tableView(_:editActionsForRowAt:)
Managing table view highlights
Editing table rows
tableView(_:willBeginEditingRowAt:)tableView(_:didEndEditingRowAt:)tableView(_:editingStyleForRowAt:)tableView(_:titleForDeleteConfirmationButtonForRowAt:)tableView(_:shouldIndentWhileEditingRowAt:)
Reordering table rows
Tracking the removal of views
tableView(_:didEndDisplaying:forRowAt:)tableView(_:didEndDisplayingHeaderView:forSection:)tableView(_:didEndDisplayingFooterView:forSection:)
Managing table view focus
tableView(_:canFocusRowAt:)tableView(_:shouldUpdateFocusIn:)tableView(_:didUpdateFocusIn:with:)indexPathForPreferredFocusedView(in:)tableView(_:selectionFollowsFocusForRowAt:)