dragInteraction(_:itemsForBeginning:)
Asks the delegate for the array of drag items for an impending drag interaction.
Declaration
func dragInteraction(_ interaction: UIDragInteraction, itemsForBeginning session: any UIDragSession) -> [UIDragItem]Parameters
- interaction:
The interaction asking for the drag items.
- session:
The current drag session.
Mentioned in
Return Value
An array of drag items to include in the drag session, or an empty array if there are no drag items for the session.
Discussion
As part of enabling dragging from a view, implement this method to return an array of one or more drag items. The system calls this method and uses this array to populate the drag session’s items property.
If the drag items represent model objects in your app that are shown in a linear order, return them in the natural first-to-last order that users expect. The system handles any order-flipping required for right-to-left scripts.
Typically, the system shows multiple dragged items as a stack of images, with the array’s first element on top. If you return an empty array, the system does not start a drag interaction.