Last active
September 5, 2017 21:37
-
-
Save YuriNachos/15bb7bef65fb52672fa9678c1e2d7640 to your computer and use it in GitHub Desktop.
Code sample #3 from drag&drop tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ViewController: UIViewController, UIDropInteractionDelegate { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| view.addInteraction(UIDropInteraction(delegate: self)) | |
| } | |
| func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) { | |
| } | |
| func dropInteraction(_ interaction: UIDropInteraction, sessionDidUpdate session: UIDropSession) -> UIDropProposal { | |
| //The operation that this interaction proposes to perform. | |
| return UIDropProposal(operation: .copy) | |
| } | |
| func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool { | |
| //Returns true if any of the session's items could create any objects of the specified class. | |
| return session.canLoadObjects(ofClass: UIImage.self) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment