UIDragInteractionDelegate.dragInteraction(_:previewForLifting:session:) should return non-optional value

Originator:an00na
Number:rdar://33135494 Date Originated:July 5 2017, 11:22 AM
Status:Closed Resolved:Behaves as Intended
Product:iOS SDK Product Version:11.0 beta 2
Classification:Other Bug Reproducible:Always
 
Area:
UIKit

Summary:
If UIDragInteractionDelegate.dragInteraction(_:previewForLifting:session:) returns nil drag doesn't work. So either this delegate method should never return nil or the implementation is buggy when the return value is nil.

Steps to Reproduce:
1. Launch sample app.
2. Try dragging the butterfly to see it doesn't work.
3. Comment out dragInteraction(_:previewForLifting:session:) in ViewController+Drag.swift then try again to see it works.

Code: https://mega.nz/#!sbAXWAza!L-0wy5glLBke-CJKhc5SzU7qkgbaHoatsLFCvuKCeao

Comments

Apple Developer Relations July 7 2017, 12:25 PM

By returning nil, you are indicating that this item should have no visible preview.

You’re correct that this is not a very good UI by itself, but it is useful in some cases.

For example, you could: - have multiple items, some of which have lift previews, and some of which do not - draw your own UI for the dragged object (like Calendar does when dragging events) - set the item’s previewProvider to provide a different preview later on


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!