Instance Method

collectionView(_:shouldShowMenuForItemAt:)

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

Declaration

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

Parameters

collectionView

The collection view object that is making the request.

indexPath

The index path of the affected item.

Return Value

true if the editing menu should be shown positioned near the item and pointing to it or false if it should not.

Discussion

If the user tap-holds a certain item in the collection view, this method (if implemented) is invoked first. Return true if you want to permit the editing menu to be displayed. Return false if the editing menu shouldn’t be shown—for example, you might return false if the corresponding item contains data that should not be copied or pasted over.

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

See Also

Managing Actions for Cells

func collectionView(UICollectionView, canPerformAction: Selector, forItemAt: IndexPath, withSender: Any?) -> Bool

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

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

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

Deprecated