Package apple.uikit.protocol
Interface UIDragInteractionDelegate
-
public interface UIDragInteractionDelegateAPI-Since: 11.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default @NotNull NSArray<? extends UIDragItem>dragInteractionItemsForAddingToSessionWithTouchAtPoint(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session, CGPoint point)To allow touches on this view to add items to an existing drag, implement `-dragInteraction:itemsForAddingToSession:withTouchAtPoint:`.@NotNull NSArray<? extends UIDragItem>dragInteractionItemsForBeginningSession(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session)Provide items to begin a drag.default voiddragInteractionItemWillAnimateCancelWithAnimator(@NotNull UIDragInteraction interaction, @NotNull UIDragItem item, @NotNull UIDragAnimating animator)Called when the cancel animation is about to start, once for each item, whether it is visible or not.default booleandragInteractionPrefersFullSizePreviewsForSession(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session)Return whether this drag's items' previews should be shown in their full original size while over the source view.default @Nullable UITargetedDragPreviewdragInteractionPreviewForCancellingItemWithDefault(@NotNull UIDragInteraction interaction, @NotNull UIDragItem item, @NotNull UITargetedDragPreview defaultPreview)Called when the drag is cancelled, once for each visible item.default @Nullable UITargetedDragPreviewdragInteractionPreviewForLiftingItemSession(@NotNull UIDragInteraction interaction, @NotNull UIDragItem item, @NotNull UIDragSession session)Provide a preview to display while lifting the drag item.default booleandragInteractionSessionAllowsMoveOperation(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session)Return whether this drag allows the "move" drop operation to happen.default voiddragInteractionSessionDidEndWithOperation(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session, long operation)Called when the user is done dragging and all related animations are completed.default voiddragInteractionSessionDidMove(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session)Called when the drag has moved (because the user's touch moved).default voiddragInteractionSessionDidTransferItems(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session)Called after a drop happened and the handler of the drop has received all of the data that it requested.default @Nullable UIDragSessiondragInteractionSessionForAddingItemsWithTouchAtPoint(@NotNull UIDragInteraction interaction, @NotNull 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.default booleandragInteractionSessionIsRestrictedToDraggingApplication(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session)Return whether this drag is restricted to only this application.default voiddragInteractionSessionWillAddItemsForInteraction(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session, @NotNull NSArray<? extends UIDragItem> items, @NotNull UIDragInteraction addingInteraction)Similar to -dragInteraction:sessionWillBegin:, but for items added to an session after it has already begun.default voiddragInteractionSessionWillBegin(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session)Called when the the items are in their fully lifted appearance, and the user has started to drag the items away.default voiddragInteractionSessionWillEndWithOperation(@NotNull UIDragInteraction interaction, @NotNull UIDragSession session, long operation)Called when the user is done dragging, and the drag will finish.default voiddragInteractionWillAnimateLiftWithAnimatorSession(@NotNull UIDragInteraction interaction, @NotNull UIDragAnimating animator, @NotNull UIDragSession session)Called when the lift animation is about to start.
-
-
-
Method Detail
-
dragInteractionItemWillAnimateCancelWithAnimator
default void dragInteractionItemWillAnimateCancelWithAnimator(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull UIDragItem item, @NotNull @NotNull 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
@NotNull default @NotNull NSArray<? extends UIDragItem> dragInteractionItemsForAddingToSessionWithTouchAtPoint(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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
@NotNull @NotNull NSArray<? extends UIDragItem> dragInteractionItemsForBeginningSession(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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
@Nullable default @Nullable UITargetedDragPreview dragInteractionPreviewForCancellingItemWithDefault(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull UIDragItem item, @NotNull @NotNull 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
@Nullable default @Nullable UITargetedDragPreview dragInteractionPreviewForLiftingItemSession(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull UIDragItem item, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull UIDragSession session, @NotNull @NotNull NSArray<? extends UIDragItem> items, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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
@Nullable default @Nullable UIDragSession dragInteractionSessionForAddingItemsWithTouchAtPoint(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull 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(@NotNull @NotNull UIDragInteraction interaction, @NotNull @NotNull UIDragAnimating animator, @NotNull @NotNull 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.
-
-