Interface UICollectionViewDelegate

    • Method Detail

      • collectionViewCanFocusItemAtIndexPath

        default boolean collectionViewCanFocusItemAtIndexPath​(@NotNull
                                                              @NotNull UICollectionView collectionView,
                                                              @NotNull
                                                              @NotNull NSIndexPath indexPath)
        Focus API-Since: 9.0
      • collectionViewCanPerformActionForItemAtIndexPathWithSender

        @Deprecated
        default boolean collectionViewCanPerformActionForItemAtIndexPathWithSender​(@NotNull
                                                                                   @NotNull UICollectionView collectionView,
                                                                                   @NotNull
                                                                                   @NotNull org.moe.natj.objc.SEL action,
                                                                                   @NotNull
                                                                                   @NotNull NSIndexPath indexPath,
                                                                                   @Nullable
                                                                                   @Nullable java.lang.Object sender)
        Deprecated.
        API-Since: 6.0 Deprecated-Since: 13.0
      • collectionViewDidDeselectItemAtIndexPath

        default void collectionViewDidDeselectItemAtIndexPath​(@NotNull
                                                              @NotNull UICollectionView collectionView,
                                                              @NotNull
                                                              @NotNull NSIndexPath indexPath)
      • collectionViewDidEndDisplayingCellForItemAtIndexPath

        default void collectionViewDidEndDisplayingCellForItemAtIndexPath​(@NotNull
                                                                          @NotNull UICollectionView collectionView,
                                                                          @NotNull
                                                                          @NotNull UICollectionViewCell cell,
                                                                          @NotNull
                                                                          @NotNull NSIndexPath indexPath)
      • collectionViewDidEndDisplayingSupplementaryViewForElementOfKindAtIndexPath

        default void collectionViewDidEndDisplayingSupplementaryViewForElementOfKindAtIndexPath​(@NotNull
                                                                                                @NotNull UICollectionView collectionView,
                                                                                                @NotNull
                                                                                                @NotNull UICollectionReusableView view,
                                                                                                @NotNull
                                                                                                @NotNull java.lang.String elementKind,
                                                                                                @NotNull
                                                                                                @NotNull NSIndexPath indexPath)
      • collectionViewDidHighlightItemAtIndexPath

        default void collectionViewDidHighlightItemAtIndexPath​(@NotNull
                                                               @NotNull UICollectionView collectionView,
                                                               @NotNull
                                                               @NotNull NSIndexPath indexPath)
      • collectionViewDidSelectItemAtIndexPath

        default void collectionViewDidSelectItemAtIndexPath​(@NotNull
                                                            @NotNull UICollectionView collectionView,
                                                            @NotNull
                                                            @NotNull NSIndexPath indexPath)
      • collectionViewDidUnhighlightItemAtIndexPath

        default void collectionViewDidUnhighlightItemAtIndexPath​(@NotNull
                                                                 @NotNull UICollectionView collectionView,
                                                                 @NotNull
                                                                 @NotNull NSIndexPath indexPath)
      • collectionViewPerformActionForItemAtIndexPathWithSender

        @Deprecated
        default void collectionViewPerformActionForItemAtIndexPathWithSender​(@NotNull
                                                                             @NotNull UICollectionView collectionView,
                                                                             @NotNull
                                                                             @NotNull org.moe.natj.objc.SEL action,
                                                                             @NotNull
                                                                             @NotNull NSIndexPath indexPath,
                                                                             @Nullable
                                                                             @Nullable java.lang.Object sender)
        Deprecated.
        API-Since: 6.0 Deprecated-Since: 13.0
      • collectionViewShouldDeselectItemAtIndexPath

        default boolean collectionViewShouldDeselectItemAtIndexPath​(@NotNull
                                                                    @NotNull UICollectionView collectionView,
                                                                    @NotNull
                                                                    @NotNull NSIndexPath indexPath)
        called when the user taps on an already-selected item in multi-select mode
      • collectionViewShouldHighlightItemAtIndexPath

        default boolean collectionViewShouldHighlightItemAtIndexPath​(@NotNull
                                                                     @NotNull UICollectionView collectionView,
                                                                     @NotNull
                                                                     @NotNull NSIndexPath indexPath)
        Methods for notification of selection/deselection and highlight/unhighlight events. The sequence of calls leading to selection from a user touch is: (when the touch begins) 1. -collectionView:shouldHighlightItemAtIndexPath: 2. -collectionView:didHighlightItemAtIndexPath: (when the touch lifts) 3. -collectionView:shouldSelectItemAtIndexPath: or -collectionView:shouldDeselectItemAtIndexPath: 4. -collectionView:didSelectItemAtIndexPath: or -collectionView:didDeselectItemAtIndexPath: 5. -collectionView:didUnhighlightItemAtIndexPath:
      • collectionViewShouldSelectItemAtIndexPath

        default boolean collectionViewShouldSelectItemAtIndexPath​(@NotNull
                                                                  @NotNull UICollectionView collectionView,
                                                                  @NotNull
                                                                  @NotNull NSIndexPath indexPath)
      • collectionViewShouldShowMenuForItemAtIndexPath

        @Deprecated
        default boolean collectionViewShouldShowMenuForItemAtIndexPath​(@NotNull
                                                                       @NotNull UICollectionView collectionView,
                                                                       @NotNull
                                                                       @NotNull NSIndexPath indexPath)
        Deprecated.
        These methods provide support for copy/paste actions on cells. All three should be implemented if any are. API-Since: 6.0 Deprecated-Since: 13.0
      • collectionViewTargetContentOffsetForProposedContentOffset

        default CGPoint collectionViewTargetContentOffsetForProposedContentOffset​(@NotNull
                                                                                  @NotNull UICollectionView collectionView,
                                                                                  CGPoint proposedContentOffset)
        customize the content offset to be applied during transition or update animations API-Since: 9.0
      • collectionViewTargetIndexPathForMoveFromItemAtIndexPathToProposedIndexPath

        @NotNull
        @Deprecated
        default @NotNull NSIndexPath collectionViewTargetIndexPathForMoveFromItemAtIndexPathToProposedIndexPath​(@NotNull
                                                                                                                @NotNull UICollectionView collectionView,
                                                                                                                @NotNull
                                                                                                                @NotNull NSIndexPath currentIndexPath,
                                                                                                                @NotNull
                                                                                                                @NotNull NSIndexPath proposedIndexPath)
        Deprecated.
        API-Since: 9.0 Deprecated-Since: 15.0
      • collectionViewWillDisplayCellForItemAtIndexPath

        default void collectionViewWillDisplayCellForItemAtIndexPath​(@NotNull
                                                                     @NotNull UICollectionView collectionView,
                                                                     @NotNull
                                                                     @NotNull UICollectionViewCell cell,
                                                                     @NotNull
                                                                     @NotNull NSIndexPath indexPath)
        API-Since: 8.0
      • collectionViewWillDisplaySupplementaryViewForElementKindAtIndexPath

        default void collectionViewWillDisplaySupplementaryViewForElementKindAtIndexPath​(@NotNull
                                                                                         @NotNull UICollectionView collectionView,
                                                                                         @NotNull
                                                                                         @NotNull UICollectionReusableView view,
                                                                                         @NotNull
                                                                                         @NotNull java.lang.String elementKind,
                                                                                         @NotNull
                                                                                         @NotNull NSIndexPath indexPath)
        API-Since: 8.0
      • indexPathForPreferredFocusedViewInCollectionView

        @Nullable
        default @Nullable NSIndexPath indexPathForPreferredFocusedViewInCollectionView​(@NotNull
                                                                                       @NotNull UICollectionView collectionView)
        API-Since: 9.0
      • collectionViewShouldSpringLoadItemAtIndexPathWithContext

        default boolean collectionViewShouldSpringLoadItemAtIndexPathWithContext​(@NotNull
                                                                                 @NotNull UICollectionView collectionView,
                                                                                 @NotNull
                                                                                 @NotNull NSIndexPath indexPath,
                                                                                 @NotNull
                                                                                 @NotNull UISpringLoadedInteractionContext context)
        Allows opting-out of spring loading for an particular item. If you want the interaction effect on a different subview of the spring loaded cell, modify the context.targetView property. The default is the cell. If this method is not implemented, the default is YES. API-Since: 11.0
      • collectionViewContextMenuConfigurationForItemAtIndexPathPoint

        @Nullable
        @Deprecated
        default @Nullable UIContextMenuConfiguration collectionViewContextMenuConfigurationForItemAtIndexPathPoint​(@NotNull
                                                                                                                   @NotNull UICollectionView collectionView,
                                                                                                                   @NotNull
                                                                                                                   @NotNull NSIndexPath indexPath,
                                                                                                                   CGPoint point)
        Deprecated.
        Called when the interaction begins.
        Parameters:
        collectionView - The @c UICollectionView.
        indexPath - IndexPath of the item for which a configuration is being requested.
        point - Touch location in the collection view's coordinate space
        Returns:
        A UIContextMenuConfiguration describing the menu to be presented. Return nil to prevent the interaction from beginning. Returning an empty configuration causes the interaction to begin then fail with a cancellation effect. You might use this to indicate to users that it's possible for a menu to be presented from this element, but that there are no actions to present at this particular time. If the non-deprecated replacement for the configuration, highlight preview, or dismissal preview methods is implemented this method is not called. API-Since: 13.0 Deprecated-Since: 16.0
      • collectionViewDidBeginMultipleSelectionInteractionAtIndexPath

        default void collectionViewDidBeginMultipleSelectionInteractionAtIndexPath​(@NotNull
                                                                                   @NotNull UICollectionView collectionView,
                                                                                   @NotNull
                                                                                   @NotNull NSIndexPath indexPath)
        Called right after allowsMultipleSelection is set to YES if -collectionView:shouldBeginMultipleSelectionInteractionAtIndexPath: returned YES. In your app, this would be a good opportunity to update the state of your UI to reflect the fact that the user is now selecting multiple items at once; such as updating buttons to say "Done" instead of "Select"/"Edit", for instance. API-Since: 13.0
      • collectionViewPreviewForDismissingContextMenuWithConfiguration

        @Nullable
        @Deprecated
        default @Nullable UITargetedPreview collectionViewPreviewForDismissingContextMenuWithConfiguration​(@NotNull
                                                                                                           @NotNull UICollectionView collectionView,
                                                                                                           @NotNull
                                                                                                           @NotNull UIContextMenuConfiguration configuration)
        Deprecated.
        Called when the interaction is about to dismiss. Return a UITargetedPreview describing the desired dismissal target. The interaction will animate the presented menu to the target. Use this to customize the dismissal animation. If the non-deprecated replacement for the configuration, highlight preview, or dismissal preview methods is implemented this method is not called.
        Parameters:
        collectionView - The @c UICollectionView.
        configuration - The configuration of the menu displayed by this interaction. API-Since: 13.0 Deprecated-Since: 16.0
      • collectionViewPreviewForHighlightingContextMenuWithConfiguration

        @Nullable
        @Deprecated
        default @Nullable UITargetedPreview collectionViewPreviewForHighlightingContextMenuWithConfiguration​(@NotNull
                                                                                                             @NotNull UICollectionView collectionView,
                                                                                                             @NotNull
                                                                                                             @NotNull UIContextMenuConfiguration configuration)
        Deprecated.
        Called when the interaction begins. Return a UITargetedPreview describing the desired highlight preview. If the non-deprecated replacement for the configuration, highlight preview, or dismissal preview methods is implemented this method is not called.
        Parameters:
        collectionView - The @c UICollectionView.
        configuration - The configuration of the menu about to be displayed by this interaction. API-Since: 13.0 Deprecated-Since: 16.0
      • collectionViewShouldBeginMultipleSelectionInteractionAtIndexPath

        default boolean collectionViewShouldBeginMultipleSelectionInteractionAtIndexPath​(@NotNull
                                                                                         @NotNull UICollectionView collectionView,
                                                                                         @NotNull
                                                                                         @NotNull NSIndexPath indexPath)
        Allows a two-finger pan gesture to automatically enable allowsMultipleSelection and start selecting multiple cells. After a multi-select gesture is recognized, this method will be called before allowsMultipleSelection is automatically set to YES to allow the user to select multiple contiguous items using a two-finger pan gesture across the constrained scroll direction. If the collection view has no constrained scroll direction (i.e., the collection view scrolls both horizontally and vertically), then this method will not be called and the multi-select gesture will be disabled. If this method is not implemented, the default is NO. API-Since: 13.0
      • collectionViewWillPerformPreviewActionForMenuWithConfigurationAnimator

        default void collectionViewWillPerformPreviewActionForMenuWithConfigurationAnimator​(@NotNull
                                                                                            @NotNull UICollectionView collectionView,
                                                                                            @NotNull
                                                                                            @NotNull UIContextMenuConfiguration configuration,
                                                                                            @NotNull
                                                                                            @NotNull UIContextMenuInteractionCommitAnimating animator)
        Called when the interaction is about to "commit" in response to the user tapping the preview.
        Parameters:
        collectionView - The @c UICollectionView.
        configuration - Configuration of the currently displayed menu.
        animator - Commit animator. Add animations to this object to run them alongside the commit transition. API-Since: 13.0
      • collectionViewDidEndMultipleSelectionInteraction

        default void collectionViewDidEndMultipleSelectionInteraction​(@NotNull
                                                                      @NotNull UICollectionView collectionView)
        Called when the multi-select interaction ends. At this point, the collection view will remain in multi-select mode, but this delegate method is called to indicate that the multiple selection gesture or hardware keyboard interaction has ended. API-Since: 13.0
      • collectionViewCanEditItemAtIndexPath

        default boolean collectionViewCanEditItemAtIndexPath​(@NotNull
                                                             @NotNull UICollectionView collectionView,
                                                             @NotNull
                                                             @NotNull NSIndexPath indexPath)
        Editing Asks the delegate to verify that the given item is editable.
        Parameters:
        collectionView - The collection view object requesting this information.
        indexPath - An index path locating an item in `collectionView`.
        Returns:
        `YES` if the item is editable; otherwise, `NO`. Defaults to `YES`. API-Since: 14.0
      • collectionViewWillDisplayContextMenuWithConfigurationAnimator

        default void collectionViewWillDisplayContextMenuWithConfigurationAnimator​(@NotNull
                                                                                   @NotNull UICollectionView collectionView,
                                                                                   @NotNull
                                                                                   @NotNull UIContextMenuConfiguration configuration,
                                                                                   @Nullable
                                                                                   @Nullable UIContextMenuInteractionAnimating animator)
        Called when the collection view is about to display a menu.
        Parameters:
        collectionView - The @c UICollectionView.
        configuration - The configuration of the menu about to be displayed.
        animator - Appearance animator. Add animations to run them alongside the appearance transition. API-Since: 13.2
      • collectionViewWillEndContextMenuInteractionWithConfigurationAnimator

        default void collectionViewWillEndContextMenuInteractionWithConfigurationAnimator​(@NotNull
                                                                                          @NotNull UICollectionView collectionView,
                                                                                          @NotNull
                                                                                          @NotNull UIContextMenuConfiguration configuration,
                                                                                          @Nullable
                                                                                          @Nullable UIContextMenuInteractionAnimating animator)
        Called when the collection view's context menu interaction is about to end.
        Parameters:
        collectionView - The @c UICollectionView.
        configuration - Ending configuration.
        animator - Disappearance animator. Add animations to run them alongside the disappearance transition. API-Since: 13.2
      • collectionViewSceneActivationConfigurationForItemAtIndexPathPoint

        @Nullable
        default @Nullable UIWindowSceneActivationConfiguration collectionViewSceneActivationConfigurationForItemAtIndexPathPoint​(@NotNull
                                                                                                                                 @NotNull UICollectionView collectionView,
                                                                                                                                 @NotNull
                                                                                                                                 @NotNull NSIndexPath indexPath,
                                                                                                                                 CGPoint point)
        Return a valid @c UIWindowSceneActivationConfiguration to allow for the cell to be expanded into a new scene. Return nil to prevent the interaction from starting.
        Parameters:
        collectionView - The collection view
        indexPath - The index path of the cell being interacted with
        point - The centroid of the interaction in the collection view's coordinate space. API-Since: 15.0
      • collectionViewSelectionFollowsFocusForItemAtIndexPath

        default boolean collectionViewSelectionFollowsFocusForItemAtIndexPath​(@NotNull
                                                                              @NotNull UICollectionView collectionView,
                                                                              @NotNull
                                                                              @NotNull NSIndexPath indexPath)
        Determines if the item at the specified index path should also become selected when focus moves to it. If the collection view's global selectionFollowsFocus is enabled, this method will allow you to override that behavior on a per-index path basis. This method is not called if selectionFollowsFocus is disabled. API-Since: 15.0
      • collectionViewTargetIndexPathForMoveOfItemFromOriginalIndexPathAtCurrentIndexPathToProposedIndexPath

        @NotNull
        default @NotNull NSIndexPath collectionViewTargetIndexPathForMoveOfItemFromOriginalIndexPathAtCurrentIndexPathToProposedIndexPath​(@NotNull
                                                                                                                                          @NotNull UICollectionView collectionView,
                                                                                                                                          @NotNull
                                                                                                                                          @NotNull NSIndexPath originalIndexPath,
                                                                                                                                          @NotNull
                                                                                                                                          @NotNull NSIndexPath currentIndexPath,
                                                                                                                                          @NotNull
                                                                                                                                          @NotNull NSIndexPath proposedIndexPath)
        API-Since: 15.0
      • collectionViewCanPerformPrimaryActionForItemAtIndexPath

        default boolean collectionViewCanPerformPrimaryActionForItemAtIndexPath​(@NotNull
                                                                                @NotNull UICollectionView collectionView,
                                                                                @NotNull
                                                                                @NotNull NSIndexPath indexPath)
        Called to determine if a primary action can be performed for the item at the given indexPath. See @c collectionView:performPrimaryActionForItemAtIndexPath: for more details about primary actions.
        Parameters:
        collectionView - This UICollectionView
        indexPath - NSIndexPath of the item
        Returns:
        `YES` if the primary action can be performed; otherwise `NO`. If not implemented, defaults to `YES` when not editing and `NO` when editing. API-Since: 16.0
      • collectionViewContextMenuConfigurationDismissalPreviewForItemAtIndexPath

        @Nullable
        default @Nullable UITargetedPreview collectionViewContextMenuConfigurationDismissalPreviewForItemAtIndexPath​(@NotNull
                                                                                                                     @NotNull UICollectionView collectionView,
                                                                                                                     @NotNull
                                                                                                                     @NotNull UIContextMenuConfiguration configuration,
                                                                                                                     @NotNull
                                                                                                                     @NotNull NSIndexPath indexPath)
        Called when a context menu presented from this collection view is dismissed. Return a @c UITargetedPreview corresponding to the item at the given indexPath.
        Parameters:
        collectionView - The @c UICollectionView.
        configuration - Configuration of the menu being dismissed.
        indexPath - Index path of the item to which the menu is being dismissed. API-Since: 16.0
      • collectionViewContextMenuConfigurationHighlightPreviewForItemAtIndexPath

        @Nullable
        default @Nullable UITargetedPreview collectionViewContextMenuConfigurationHighlightPreviewForItemAtIndexPath​(@NotNull
                                                                                                                     @NotNull UICollectionView collectionView,
                                                                                                                     @NotNull
                                                                                                                     @NotNull UIContextMenuConfiguration configuration,
                                                                                                                     @NotNull
                                                                                                                     @NotNull NSIndexPath indexPath)
        Called when a context menu interaction begins in this collection view to request a preview for the interaction's initial highlight effect. Return a @c UITargetedPreview corresponding to the item at the given indexPath.
        Parameters:
        collectionView - The @c UICollectionView.
        configuration - Configuration of the menu that will be presented if the interaction proceeds.
        indexPath - Index path of the item at which the interaction is occurring. API-Since: 16.0
      • collectionViewContextMenuConfigurationForItemsAtIndexPathsPoint

        @Nullable
        default @Nullable UIContextMenuConfiguration collectionViewContextMenuConfigurationForItemsAtIndexPathsPoint​(@NotNull
                                                                                                                     @NotNull UICollectionView collectionView,
                                                                                                                     @NotNull
                                                                                                                     @NotNull NSArray<? extends NSIndexPath> indexPaths,
                                                                                                                     CGPoint point)
        Called when a context menu is invoked from this collection view. The @c indexPaths array may contain 0-many items: - An empty array indicates that the menu was invoked in the space between cells (or any location that does not map to an item index path). - An array with multiple index paths indicates that the menu was invoked on an item within a multiple selection. API-Since: 16.0
        Parameters:
        collectionView - The @c UICollectionView.
        indexPaths - An array of index paths on which the menu acts.
        point - Touch location in the collection view's coordinate space.
        Returns:
        A @c UIContextMenuConfiguration describing the menu to be presented. Return nil to prevent the interaction from beginning. Returning an empty configuration causes the interaction to begin then fail with a cancellation effect. You might use this to indicate to users that it's possible for a menu to be presented from this element, but that there are no actions to present at this particular time.
      • collectionViewPerformPrimaryActionForItemAtIndexPath

        default void collectionViewPerformPrimaryActionForItemAtIndexPath​(@NotNull
                                                                          @NotNull UICollectionView collectionView,
                                                                          @NotNull
                                                                          @NotNull NSIndexPath indexPath)
        Called when the primary action should be performed for the item at the given indexPath. Primary actions allow you to distinguish between a change of selection (which can be based on focus changes or other indirect selection changes) and distinct user actions. Primary actions are performed when the user selects a cell without extending an existing selection. This is called after @c shouldSelectItem and @c didSelectItem , regardless of whether the cell's selection state was allowed to change. As an example, use @c didSelectItemAtIndexPath for updating state in the current view controller (i.e. buttons, title, etc) and use the primary action for navigation or showing another split view column.
        Parameters:
        collectionView - This UICollectionView
        indexPath - NSIndexPath of the item to perform the action on API-Since: 16.0