Instance Method


Asks the delegate whether the item at the specified index path can be focused.


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



The collection view object requesting this information.


The index path of an item in the collection view.

Return Value

true if the item can receive be focused or false if it can not.


You can use this method, or a cell’s canBecomeFocused method, to control which items in the collection view can receive focus. The focus engine calls the cell’s canBecomeFocused method first, the default implementation of which defers to the collection view and this delegate method.

If you do not implement this method, the ability to focus on items depends on whether the collection view’s items are selectable. When the items are selectable, they can also be focused as if this method had returned true; otherwise, they do not receive focus.

See Also

Managing Focus in a Collection View