Instance Method


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


optional func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool



The collection view object that is making the request.


The selector identifying the action to be performed.


The index path of the affected item.


The object that wants to initiate the action.

Return Value

true if the command corresponding to action should appear in the editing menu or false if it should not.


This method is invoked after the collectionView(_:shouldShowMenuForItemAt:) method. It gives you the opportunity to exclude commands from the editing menu. For example, the user might have copied some content from one item and wants to paste it into another item that cannot accept the content. In such a case, your method could return false to prevent the display of the relevant command.

If you do not implement this method, the default return value is false.

See Also

Managing Actions for Cells

func collectionView(UICollectionView, shouldShowMenuForItemAt: IndexPath) -> Bool

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

func collectionView(UICollectionView, performAction: Selector, forItemAt: IndexPath, withSender: Any?)

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