collectionView(_:contextMenuConfigurationForItemAt:point:)
Returns a context menu configuration for the item at a point.
Declaration
optional func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration?Parameters
- collectionView:
The collection view containing the item.
- indexPath:
The index path of the item for which a configuration is being requested.
- point:
The location of the interaction in the collection view’s coordinate space.
Return Value
A contextual menu configuration object describing the menu to be presented. Returning nil prevents the interaction from beginning. Returning an empty configuration object causes the interaction to begin, and then end with a cancellation effect.
Discussion
You can use the cancellation effect from returning an empty configuration to indicate to users that it’s possible for a menu to be presented from this item, but that there are no actions to present at this particular time.
See Also
Deprecated
collectionView(_:targetIndexPathForMoveFromItemAt:toProposedIndexPath:)collectionView(_:previewForDismissingContextMenuWithConfiguration:)collectionView(_:previewForHighlightingContextMenuWithConfiguration:)collectionView(_:shouldShowMenuForItemAt:)collectionView(_:canPerformAction:forItemAt:withSender:)collectionView(_:performAction:forItemAt:withSender:)