Asks the delegate whether a change in focus should occur.
- iOS 9.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
The collection view object requesting this information.
The context object containing metadata associated with the focus change. This object contains the index path of the previously focused item and the item targeted to receive focus next. Use this information to determine if the focus change should occur.
true if the focus change should occur or
false if it should not.
Before a focus change can occur, the focus engine asks all affected views if such a change should occur. In response, the collection view calls this method to give you the opportunity to allow or prevent the change. Return this method to prevent changes that should not occur. For example, you might use it to ensure that the navigation between cells occurs in a specific order.
If you do not implement this method, the collection view assumes a return value of
If you subclass
UICollection, you can also implement the same behavior by overriding the
should method, which is defined by the
UIFocus protocol and adopted by all views.