<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITableViewDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITableViewDelegate"
  },
  "title" : "UITableViewDelegate"
}
-->

# UITableViewDelegate

Methods for managing selections, configuring section headers and footers, deleting and reordering cells, and performing other actions in a table view.

```
@MainActor protocol UITableViewDelegate : UIScrollViewDelegate
```

## Overview

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 <doc://com.apple.documentation/documentation/Foundation/IndexPath>. For information about how to interpret row and section indexes, see [`Specify the location of rows and sections`](/documentation/UIKit/UITableViewDataSource#Specify-the-location-of-rows-and-sections).

## Topics

### Configuring rows for the table view

[`tableView(_:willDisplay:forRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willDisplay:forRowAt:))

Tells the delegate the table view is about to draw a cell for a particular row.

[`tableView(_:indentationLevelForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:indentationLevelForRowAt:))

Asks the delegate to return the level of indentation for a row in a given section.

[`tableView(_:shouldSpringLoadRowAt:with:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:shouldSpringLoadRowAt:with:))

Called to let you fine tune the spring-loading behavior of the rows in a table.

### Responding to row selections

[Handling row selection in a table view](/documentation/UIKit/handling-row-selection-in-a-table-view)

Detect when a user taps a table view cell so your app can take the next indicated action.

[Selecting multiple items with a two-finger pan gesture](/documentation/UIKit/selecting-multiple-items-with-a-two-finger-pan-gesture)

Accelerate user selection of multiple items using the multiselect gesture on table and collection views.

[`tableView(_:willSelectRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willSelectRowAt:))

Tells the delegate a row is about to be selected.

[`tableView(_:didSelectRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didSelectRowAt:))

Tells the delegate a row is selected.

[`tableView(_:willDeselectRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willDeselectRowAt:))

Tells the delegate that a specified row is about to be deselected.

[`tableView(_:didDeselectRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didDeselectRowAt:))

Tells the delegate that the specified row is now deselected.

[`tableView(_:shouldBeginMultipleSelectionInteractionAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:shouldBeginMultipleSelectionInteractionAt:))

Asks the delegate whether the user can use a two-finger pan gesture to select multiple items in a table view.

[`tableView(_:didBeginMultipleSelectionInteractionAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didBeginMultipleSelectionInteractionAt:))

Tells the delegate when the user starts using a two-finger pan gesture to select multiple rows in a table view.

[`tableViewDidEndMultipleSelectionInteraction(_:)`](/documentation/UIKit/UITableViewDelegate/tableViewDidEndMultipleSelectionInteraction(_:))

Tells the delegate when the user stops using a two-finger pan gesture to select multiple rows in a table view.

### Providing custom header and footer views

[`tableView(_:viewForHeaderInSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:viewForHeaderInSection:))

Asks the delegate for a view to display in the header of the specified section of the table view.

[`tableView(_:viewForFooterInSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:viewForFooterInSection:))

Asks the delegate for a view to display in the footer of the specified section of the table view.

[`tableView(_:willDisplayHeaderView:forSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willDisplayHeaderView:forSection:))

Tells the delegate that the table is about to display the header view for the specified section.

[`tableView(_:willDisplayFooterView:forSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willDisplayFooterView:forSection:))

Tells the delegate that the table is about to display the footer view for the specified section.

### Providing header, footer, and row heights

[`tableView(_:heightForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:heightForRowAt:))

Asks the delegate for the height to use for a row in a specified location.

[`tableView(_:heightForHeaderInSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:heightForHeaderInSection:))

Asks the delegate for the height to use for the header of a particular section.

[`tableView(_:heightForFooterInSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:heightForFooterInSection:))

Asks the delegate for the height to use for the footer of a particular section.

[`automaticDimension`](/documentation/UIKit/UITableView/automaticDimension)

A constant representing the default value for a given dimension.

### Estimating heights for the table’s content

[`tableView(_:estimatedHeightForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:estimatedHeightForRowAt:))

Asks the delegate for the estimated height of a row in a specified location.

[`tableView(_:estimatedHeightForHeaderInSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:estimatedHeightForHeaderInSection:))

Asks the delegate for the estimated height of the header of a particular section.

[`tableView(_:estimatedHeightForFooterInSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:estimatedHeightForFooterInSection:))

Asks the delegate for the estimated height of the footer of a particular section.

### Managing accessory views

[`tableView:accessoryTypeForRowWithIndexPath:`](/documentation/UIKit/UITableViewDelegate/tableView:accessoryTypeForRowWithIndexPath:)

Asks the delegate for the type of standard accessory view to use as a disclosure control for the specified row.

[`tableView(_:accessoryButtonTappedForRowWith:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:accessoryButtonTappedForRowWith:))

Tells the delegate that the user tapped the detail button for the specified row.

### Managing context menus

[Adding context menus in your app](/documentation/UIKit/adding-context-menus-in-your-app)

Provide quick access to useful actions by adding context menus to your iOS app.

[`tableView(_:contextMenuConfigurationForRowAt:point:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:contextMenuConfigurationForRowAt:point:))

Returns a context menu configuration for the row at a point.

[`tableView(_:previewForDismissingContextMenuWithConfiguration:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:previewForDismissingContextMenuWithConfiguration:))

Returns the destination view when dismissing a context menu.

[`tableView(_:previewForHighlightingContextMenuWithConfiguration:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:previewForHighlightingContextMenuWithConfiguration:))

Returns a view to override the default preview the table view created.

[`tableView(_:willDisplayContextMenu:animator:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willDisplayContextMenu:animator:))

Informs the delegate when a context menu will appear.

[`tableView(_:willEndContextMenuInteraction:animator:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willEndContextMenuInteraction:animator:))

Informs the delegate when a context menu will disappear.

[`tableView(_:willPerformPreviewActionForMenuWith:animator:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willPerformPreviewActionForMenuWith:animator:))

Informs the delegate when a user triggers a commit by tapping the preview.

### Responding to row actions

[`tableView(_:leadingSwipeActionsConfigurationForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:leadingSwipeActionsConfigurationForRowAt:))

Returns the swipe actions to display on the leading edge of the row.

[`tableView(_:trailingSwipeActionsConfigurationForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:trailingSwipeActionsConfigurationForRowAt:))

Returns the swipe actions to display on the trailing edge of the row.

[`tableView(_:shouldShowMenuForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:shouldShowMenuForRowAt:))

Asks the delegate if the editing menu should be shown for a certain row.

[`tableView(_:canPerformAction:forRowAt:withSender:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:canPerformAction:forRowAt:withSender:))

Asks the delegate if the editing menu should omit the Copy or Paste command for a given row.

[`tableView(_:performAction:forRowAt:withSender:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:performAction:forRowAt:withSender:))

Tells the delegate to perform a copy or paste operation on the content of a given row.

[`tableView(_:editActionsForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:editActionsForRowAt:))

Asks the delegate for the actions to display in response to a swipe in the specified row.

### Managing table view highlights

[`tableView(_:shouldHighlightRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:shouldHighlightRowAt:))

Asks the delegate if the specified row should be highlighted.

[`tableView(_:didHighlightRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didHighlightRowAt:))

Tells the delegate that the specified row was highlighted.

[`tableView(_:didUnhighlightRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didUnhighlightRowAt:))

Tells the delegate that the highlight was removed from the row at the specified index path.

### Editing table rows

[`tableView(_:willBeginEditingRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:willBeginEditingRowAt:))

Tells the delegate that the table view is about to go into editing mode.

[`tableView(_:didEndEditingRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didEndEditingRowAt:))

Tells the delegate that the table view has left editing mode.

[`tableView(_:editingStyleForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:editingStyleForRowAt:))

Asks the delegate for the editing style of a row at a particular location in a table view.

[`tableView(_:titleForDeleteConfirmationButtonForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:titleForDeleteConfirmationButtonForRowAt:))

Changes the default title of the delete-confirmation button.

[`tableView(_:shouldIndentWhileEditingRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:shouldIndentWhileEditingRowAt:))

Asks the delegate whether the background of the specified row should be indented while the table view is in editing mode.

### Reordering table rows

[`tableView(_:targetIndexPathForMoveFromRowAt:toProposedIndexPath:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:targetIndexPathForMoveFromRowAt:toProposedIndexPath:))

Asks the delegate to return a new index path to retarget a proposed move of a row.

### Tracking the removal of views

[`tableView(_:didEndDisplaying:forRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didEndDisplaying:forRowAt:))

Tells the delegate that the specified cell was removed from the table.

[`tableView(_:didEndDisplayingHeaderView:forSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didEndDisplayingHeaderView:forSection:))

Tells the delegate that the specified header view was removed from the table.

[`tableView(_:didEndDisplayingFooterView:forSection:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didEndDisplayingFooterView:forSection:))

Tells the delegate that the specified footer view was removed from the table.

### Managing table view focus

[`tableView(_:canFocusRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:canFocusRowAt:))

Asks the delegate whether the cell at the specified index path is itself focusable.

[`tableView(_:shouldUpdateFocusIn:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:shouldUpdateFocusIn:))

Asks the delegate whether the focus update specified by the context is allowed to occur.

[`tableView(_:didUpdateFocusIn:with:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:didUpdateFocusIn:with:))

Tells the delegate that a focus update specified by the context has just occurred.

[`indexPathForPreferredFocusedView(in:)`](/documentation/UIKit/UITableViewDelegate/indexPathForPreferredFocusedView(in:))

Asks the delegate for the table view’s index path for the preferred focused view.

[`tableView(_:selectionFollowsFocusForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:selectionFollowsFocusForRowAt:))

Asks the delegate whether to relate selection and focus behavior for the row at the corresponding index path.

### Performing primary actions

[`tableView(_:canPerformPrimaryActionForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:canPerformPrimaryActionForRowAt:))

Asks the delegate whether to perform a primary action for the row at the specified index path.

[`tableView(_:performPrimaryActionForRowAt:)`](/documentation/UIKit/UITableViewDelegate/tableView(_:performPrimaryActionForRowAt:))

Tells the delegate to perform the primary action for the row at the specified index path.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)