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

# UICollectionViewDelegate

The methods adopted by the object you use to manage user interactions with items in a collection view.

```
@MainActor protocol UICollectionViewDelegate : UIScrollViewDelegate
```

## Overview

A collection view delegate manages user interactions with the collection view’s contents, including item selection, highlighting, and performing actions on those items. The methods of this protocol are all optional.

When configuring the collection view object, assign your delegate object to its [`delegate`](/documentation/UIKit/UICollectionView/delegate) property. For more information, see [`UICollectionView`](/documentation/UIKit/UICollectionView).

## Topics

### Managing the selected cells

[Changing the appearance of selected and highlighted cells](/documentation/UIKit/changing-the-appearance-of-selected-and-highlighted-cells)

Provide visual feedback to the user about the state of a cell and the transition between states.

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

[`-  collectionView:shouldSelectItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldSelectItemAt:))

Asks the delegate if the specified item should be selected.

[`-  collectionView:didSelectItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didSelectItemAt:))

Tells the delegate that the item at the specified index path was selected.

[`-  collectionView:shouldDeselectItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldDeselectItemAt:))

Asks the delegate if the specified item should be deselected.

[`-  collectionView:didDeselectItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didDeselectItemAt:))

Tells the delegate that the item at the specified path was deselected.

[`-  collectionView:shouldBeginMultipleSelectionInteractionAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldBeginMultipleSelectionInteractionAt:))

Asks the delegate whether the user can select multiple items using a two-finger pan gesture in a collection view.

[`-  collectionView:didBeginMultipleSelectionInteractionAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didBeginMultipleSelectionInteractionAt:))

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

[`-  collectionViewDidEndMultipleSelectionInteraction:`](/documentation/UIKit/UICollectionViewDelegate/collectionViewDidEndMultipleSelectionInteraction(_:))

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

### Managing cell highlighting

[`-  collectionView:shouldHighlightItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldHighlightItemAt:))

Asks the delegate if the item should be highlighted during tracking.

[`-  collectionView:didHighlightItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didHighlightItemAt:))

Tells the delegate that the item at the specified index path was highlighted.

[`-  collectionView:didUnhighlightItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didUnhighlightItemAt:))

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

### Tracking the addition and removal of views

[`-  collectionView:willDisplayCell:forItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:willDisplay:forItemAt:))

Tells the delegate that the specified cell is about to be displayed in the collection view.

[`-  collectionView:willDisplaySupplementaryView:forElementKind:atIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:willDisplaySupplementaryView:forElementKind:at:))

Tells the delegate that the specified supplementary view is about to be displayed in the collection view.

[`-  collectionView:didEndDisplayingCell:forItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didEndDisplaying:forItemAt:))

Tells the delegate that the specified cell was removed from the collection view.

[`-  collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didEndDisplayingSupplementaryView:forElementOfKind:at:))

Tells the delegate that the specified supplementary view was removed from the collection view.

### Handling layout changes

[`-  collectionView:transitionLayoutForOldLayout:newLayout:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:transitionLayoutForOldLayout:newLayout:))

Asks for the custom transition layout to use when moving between the specified layouts.

[`-  collectionView:targetContentOffsetForProposedContentOffset:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:targetContentOffsetForProposedContentOffset:))

Gives the delegate an opportunity to customize the content offset for layout changes and animated updates.

[`-  collectionView:targetIndexPathForMoveOfItemFromOriginalIndexPath:atCurrentIndexPath:toProposedIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:targetIndexPathForMoveOfItemFromOriginalIndexPath:atCurrentIndexPath:toProposedIndexPath:))

Asks the delegate for the index path to use when moving an item.

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

[`-  collectionView:willDisplayContextMenuWithConfiguration:animator:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:willDisplayContextMenu:animator:))

Informs the delegate when a context menu will appear.

[`-  collectionView:willEndContextMenuInteractionWithConfiguration:animator:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:willEndContextMenuInteraction:animator:))

Informs the delegate when a context menu will disappear.

[`-  collectionView:willPerformPreviewActionForMenuWithConfiguration:animator:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:willPerformPreviewActionForMenuWith:animator:))

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

[`-  collectionView:contextMenuConfigurationForItemsAtIndexPaths:point:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:contextMenuConfigurationForItemsAt:point:))

Asks the delegate for a context-menu configuration for the items at the specified index paths.

[`-  collectionView:contextMenuConfiguration:highlightPreviewForItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:contextMenuConfiguration:highlightPreviewForItemAt:))

Asks the delegate for a preview of the item at the specified index path when a context-menu interaction begins.

[`-  collectionView:contextMenuConfiguration:dismissalPreviewForItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:contextMenuConfiguration:dismissalPreviewForItemAt:))

Asks the delegate for a preview of the item at the specified index path when a context-menu interaction ends.

### Working with focus

[`-  collectionView:canFocusItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:canFocusItemAt:))

Asks the delegate whether the item at the specified index path can be focused.

[`-  indexPathForPreferredFocusedViewInCollectionView:`](/documentation/UIKit/UICollectionViewDelegate/indexPathForPreferredFocusedView(in:))

Asks the delegate for the index path of the cell that should be focused.

[`-  collectionView:shouldUpdateFocusInContext:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldUpdateFocusIn:))

Asks the delegate whether a change in focus should occur.

[`-  collectionView:didUpdateFocusInContext:withAnimationCoordinator:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didUpdateFocusIn:with:))

Tells the delegate that a focus update occurred.

[`-  collectionView:selectionFollowsFocusForItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:selectionFollowsFocusForItemAt:))

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

### Editing items

[`-  collectionView:canEditItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:canEditItemAt:))

Determines whether the specified item is editable.

### Managing actions for cells

[`-  collectionView:canPerformPrimaryActionForItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:canPerformPrimaryActionForItemAt:))

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

[`-  collectionView:performPrimaryActionForItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:performPrimaryActionForItemAt:))

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

### Handling scene transitions

[`-  collectionView:sceneActivationConfigurationForItemAtIndexPath:point:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:sceneActivationConfigurationForItemAt:point:))

Returns a scene activation configuration that allows the cell to expand into a new scene.

### Controlling the spring-loading behavior

[`-  collectionView:shouldSpringLoadItemAtIndexPath:withContext:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldSpringLoadItemAt:with:))

Determines whether the spring-loading interaction effect is displayed for the specified item.

### Deprecated

[`-  collectionView:targetIndexPathForMoveFromItemAtIndexPath:toProposedIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:targetIndexPathForMoveFromItemAt:toProposedIndexPath:))

Asks the delegate for the index path to use when moving an item.

[`-  collectionView:contextMenuConfigurationForItemAtIndexPath:point:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:contextMenuConfigurationForItemAt:point:))

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

[`-  collectionView:previewForDismissingContextMenuWithConfiguration:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:previewForDismissingContextMenuWithConfiguration:))

Returns the destination view when dismissing a context menu.

[`-  collectionView:previewForHighlightingContextMenuWithConfiguration:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:previewForHighlightingContextMenuWithConfiguration:))

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

[`-  collectionView:shouldShowMenuForItemAtIndexPath:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldShowMenuForItemAt:))

Asks the delegate if an action menu should be displayed for the specified item.

[`-  collectionView:canPerformAction:forItemAtIndexPath:withSender:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:canPerformAction:forItemAt:withSender:))

Asks the delegate if it can perform the specified action on an item in the collection view.

[`-  collectionView:performAction:forItemAtIndexPath:withSender:`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:performAction:forItemAt:withSender:))

Tells the delegate to perform the specified action on an item in the collection view.

## Relationships

### Inherited By

[`UICollectionViewDelegateFlowLayout`](/documentation/UIKit/UICollectionViewDelegateFlowLayout)

### Inherits From

[`UIScrollViewDelegate`](/documentation/UIKit/UIScrollViewDelegate)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Conforming Types

[`UICollectionViewController`](/documentation/UIKit/UICollectionViewController)

---

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)