Contents

collectionView(_:selectionFollowsFocusForItemAt:)

Asks the delegate whether to relate selection and focus behavior for the cell at the corresponding index path.

Declaration

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

Parameters

  • collectionView:

    The collection view making the request.

  • indexPath:

    The index path of the cell to determine selection and focus behavior for.

Return Value

true if you want to automatically select the cell at the specified index path when focus moves to it; otherwise, false.

Discussion

If the collection view’s selectionFollowsFocus property is true and you return false from this delegate method, focus still moves to the cell when the user selects it. However, when focus moves to the cell, the cell doesn’t automatically select.

See Also

Working with focus