<!--
{
  "availability" : [
    "iOS: 6.0.0 - 13.0.0",
    "iPadOS: 6.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "tvOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICollectionViewDelegate/collectionView(_:canPerformAction:forItemAt:withSender:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UICollectionViewDelegate(im)collectionView:canPerformAction:forItemAtIndexPath:withSender:"
  },
  "title" : "collectionView(_:canPerformAction:forItemAt:withSender:)"
}
-->

# collectionView(_:canPerformAction:forItemAt:withSender:)

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
```

## Parameters

`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

<doc://com.apple.documentation/documentation/Swift/true> if the command corresponding to action should appear in the editing menu or <doc://com.apple.documentation/documentation/Swift/false> if it should not.

## Discussion

This method is invoked after the [`collectionView(_:shouldShowMenuForItemAt:)`](/documentation/UIKit/UICollectionViewDelegate/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 <doc://com.apple.documentation/documentation/Swift/false> to prevent the display of the relevant command.

If you do not implement this method, the default return value is <doc://com.apple.documentation/documentation/Swift/false>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)