Skip to content

Instantly share code, notes, and snippets.

@YuriNachos
Last active September 5, 2017 21:37
Show Gist options
  • Select an option

  • Save YuriNachos/15bb7bef65fb52672fa9678c1e2d7640 to your computer and use it in GitHub Desktop.

Select an option

Save YuriNachos/15bb7bef65fb52672fa9678c1e2d7640 to your computer and use it in GitHub Desktop.
Code sample #3 from drag&drop tutorial
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