collectionView(_:canPerformAction:forItemAt:withSender:)
Asks the delegate if it can perform the specified action on an item in the collection view.
Declaration
optional func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> BoolParameters
- collectionView:
The collection view object that is making the request.
- action:
The selector identifying the action to be performed.
- indexPath:
The index path of the affected item.
- sender:
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.
Discussion
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
Deprecated
collectionView(_:targetIndexPathForMoveFromItemAt:toProposedIndexPath:)collectionView(_:contextMenuConfigurationForItemAt:point:)collectionView(_:previewForDismissingContextMenuWithConfiguration:)collectionView(_:previewForHighlightingContextMenuWithConfiguration:)collectionView(_:shouldShowMenuForItemAt:)collectionView(_:performAction:forItemAt:withSender:)