Instance Method

indexPathForItem(at:)

Returns the index path of the item at the specified point in the collection view.

Declaration

func indexPathForItem(at point: CGPoint) -> IndexPath?

Parameters

point

A point in the collection view’s coordinate system.

Return Value

The index path of the item at the specified point or nil if no item was found at the specified point.

Discussion

This method relies on the layout information provided by the associated layout object to determine which item contains the point.

See Also

Locating Items and Views in the Collection View

var indexPathsForVisibleItems: [IndexPath]

An array of the visible items in the collection view.

func indexPath(for: UICollectionViewCell) -> IndexPath?

Returns the index path of the specified cell.

func cellForItem(at: IndexPath) -> UICollectionViewCell?

Returns the visible cell object at the specified index path.

func indexPathsForVisibleSupplementaryElements(ofKind: String) -> [IndexPath]

Returns the index paths of all visible supplementary views of the specified type.

func visibleSupplementaryViews(ofKind: String) -> [UICollectionReusableView]

Returns an array of the visible supplementary views of the specified kind.