---
title: "collectionView(_:willDisplay:forItemAt:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uicollectionviewdelegate/collectionview(_:willdisplay:foritemat:)"
---

# collectionView(_:willDisplay:forItemAt:)

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

## Declaration

```swift
optional func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)
```

## Parameters

- `collectionView`: The collection view object that is adding the cell.
- `cell`: The cell object being added.
- `indexPath`: The index path of the data item that the cell represents.

## Discussion

Discussion The collection view calls this method before adding a cell to its content. Use this method to detect cell additions, as opposed to monitoring the cell itself to see when it appears.

## See Also

### Tracking the addition and removal of views

- [collectionView(_:willDisplaySupplementaryView:forElementKind:at:)](uikit/uicollectionviewdelegate/collectionview(_:willdisplaysupplementaryview:forelementkind:at:).md)
- [collectionView(_:didEndDisplaying:forItemAt:)](uikit/uicollectionviewdelegate/collectionview(_:didenddisplaying:foritemat:).md)
- [collectionView(_:didEndDisplayingSupplementaryView:forElementOfKind:at:)](uikit/uicollectionviewdelegate/collectionview(_:didenddisplayingsupplementaryview:forelementofkind:at:).md)
