Interface UIDragInteractionDelegate


  • public interface UIDragInteractionDelegate
    • Method Detail

      • dragInteractionItemWillAnimateCancelWithAnimator

        default void dragInteractionItemWillAnimateCancelWithAnimator​(UIDragInteraction interaction,
                                                                      UIDragItem item,
                                                                      UIDragAnimating animator)
        Called when the cancel animation is about to start, once for each item, whether it is visible or not. Use the animator to animate your own changes alongside the system animation.
      • dragInteractionItemsForAddingToSessionWithTouchAtPoint

        default NSArray<? extends UIDragItem> dragInteractionItemsForAddingToSessionWithTouchAtPoint​(UIDragInteraction interaction,
                                                                                                     UIDragSession session,
                                                                                                     CGPoint point)
        To allow touches on this view to add items to an existing drag, implement `-dragInteraction:itemsForAddingToSession:withTouchAtPoint:`. If the provided session is an appropriate one to use, then return an array of items, just like in `-dragInteraction:itemsForBeginningSession:`. They will be added to the drag session. Afterwards, `-dragInteraction:session:willAddItems:forInteraction:` will be sent to each interaction which has contributed items to the session, including this one. Otherwise, return an empty array. No items will be added, and the touch will be handled as if the other drag session did not exist. If this method is not implemented, acts as though an an empty array was returned. Use the point, in the view's coordinate space, to determine what part of your view has been touched.
      • dragInteractionItemsForBeginningSession

        NSArray<? extends UIDragItem> dragInteractionItemsForBeginningSession​(UIDragInteraction interaction,
                                                                              UIDragSession session)
        Provide items to begin a drag. If these items represent things that are displayed in a linear order (for example, rows in a table), provide them in the same order, first to last. If an empty array is returned, then no drag will begin.
      • dragInteractionPrefersFullSizePreviewsForSession

        default boolean dragInteractionPrefersFullSizePreviewsForSession​(UIDragInteraction interaction,
                                                                         UIDragSession session)
        Return whether this drag's items' previews should be shown in their full original size while over the source view. For instance, if you are reordering items, you may want them not to shrink like they otherwise would. If not implemented, defaults to false.
      • dragInteractionPreviewForCancellingItemWithDefault

        default UITargetedDragPreview dragInteractionPreviewForCancellingItemWithDefault​(UIDragInteraction interaction,
                                                                                         UIDragItem item,
                                                                                         UITargetedDragPreview defaultPreview)
        Called when the drag is cancelled, once for each visible item. Provide a preview to animate the item back to where it belongs. We provide `defaultPreview` which would move the current preview back to where it came from. You may return: - defaultPreview, to use it as-is - nil, to fade the drag item in place - [defaultPreview retargetedPreviewWithTarget:] to move the preview to a different target - a UITargetedDragPreview that you create however you like
      • dragInteractionPreviewForLiftingItemSession

        default UITargetedDragPreview dragInteractionPreviewForLiftingItemSession​(UIDragInteraction interaction,
                                                                                  UIDragItem item,
                                                                                  UIDragSession session)
        Provide a preview to display while lifting the drag item. Return nil to indicate that this item is not visible and should have no lift animation. If not implemented, a UITargetedDragPreview initialized with interaction.view will be used.
      • dragInteractionSessionDidEndWithOperation

        default void dragInteractionSessionDidEndWithOperation​(UIDragInteraction interaction,
                                                               UIDragSession session,
                                                               long operation)
        Called when the user is done dragging and all related animations are completed. The app should now return to its normal appearance. If the operation is UIDropOperationCopy or UIDropOperationMove, then data transfer will begin, and -dragInteraction:sessionDidTransferItems: will be called later.
      • dragInteractionSessionWillAddItemsForInteraction

        default void dragInteractionSessionWillAddItemsForInteraction​(UIDragInteraction interaction,
                                                                      UIDragSession session,
                                                                      NSArray<? extends UIDragItem> items,
                                                                      UIDragInteraction addingInteraction)
        Similar to -dragInteraction:sessionWillBegin:, but for items added to an session after it has already begun. Note that the interaction that is causing the items to be added may be different than the interaction that started the drag. This method is called on the delegates of all interactions that ever added items to this session. `addingInteraction` is the interaction that is causing these new items to be dragged.
      • dragInteractionSessionWillEndWithOperation

        default void dragInteractionSessionWillEndWithOperation​(UIDragInteraction interaction,
                                                                UIDragSession session,
                                                                long operation)
        Called when the user is done dragging, and the drag will finish. If the operation is UIDropOperationCancel or UIDropOperationForbidden, the delegate should prepare its views to show an appropriate appearance before the cancel animation starts.
      • dragInteractionSessionAllowsMoveOperation

        default boolean dragInteractionSessionAllowsMoveOperation​(UIDragInteraction interaction,
                                                                  UIDragSession session)
        Return whether this drag allows the "move" drop operation to happen. This only applies to drops inside the same app. Drops in other apps are always copies. If true, then a UIDropInteraction's delegate's -dropInteraction:sessionDidUpdate: may choose to return UIDropOperationMove, and that operation will be provided to -dragInteraction:session:willEndWithOperation: and -dragInteraction:session:didEndWithOperation:. If not implemented, defaults to true.
      • dragInteractionSessionDidMove

        default void dragInteractionSessionDidMove​(UIDragInteraction interaction,
                                                   UIDragSession session)
        Called when the drag has moved (because the user's touch moved). Use -[UIDragSession locationInView:] to get its new location.
      • dragInteractionSessionDidTransferItems

        default void dragInteractionSessionDidTransferItems​(UIDragInteraction interaction,
                                                            UIDragSession session)
        Called after a drop happened and the handler of the drop has received all of the data that it requested. You may now clean up any extra information relating to those items or their item providers.
      • dragInteractionSessionForAddingItemsWithTouchAtPoint

        default UIDragSession dragInteractionSessionForAddingItemsWithTouchAtPoint​(UIDragInteraction interaction,
                                                                                   NSArray<?> sessions,
                                                                                   CGPoint point)
        If there are two or more existing drag sessions, it may not be clear to the user which session items will be added to. Therefore, by default, we do not add to any session. If you *do* want to add the item to a session, implement `-dragInteraction:sessionForAddingItems:withTouchAtPoint:` and return the appropriate session. This should be rare. To continue without adding items, return nil. If this method is not implemented, defaults to nil.
      • dragInteractionSessionIsRestrictedToDraggingApplication

        default boolean dragInteractionSessionIsRestrictedToDraggingApplication​(UIDragInteraction interaction,
                                                                                UIDragSession session)
        Return whether this drag is restricted to only this application. If true, then the drag will be restricted. Only this application will be able to see the drag, and other applications will not. If the user drops it on another application, the drag will be cancelled. If false, then the drag is not restricted. Other applications may see the drag, and the user may drop it onto them. If not implemented, defaults to false. Note that this method is called only on devices that support dragging across applications.
      • dragInteractionSessionWillBegin

        default void dragInteractionSessionWillBegin​(UIDragInteraction interaction,
                                                     UIDragSession session)
        Called when the the items are in their fully lifted appearance, and the user has started to drag the items away.
      • dragInteractionWillAnimateLiftWithAnimatorSession

        default void dragInteractionWillAnimateLiftWithAnimatorSession​(UIDragInteraction interaction,
                                                                       UIDragAnimating animator,
                                                                       UIDragSession session)
        Called when the lift animation is about to start. Use the animator to animate your own changes alongside the system animation, or to be called when the lift animation completes.