Created
August 9, 2018 17:21
-
-
Save CibelePaulinoAndrade/9821eed2e436a1e6583c53cd368d3036 to your computer and use it in GitHub Desktop.
sessionDidUpdate - Drag and Drop
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
func dropInteraction(_ interaction: UIDropInteraction, sessionDidUpdate session: UIDropSession) -> UIDropProposal { | |
let location = session.location(in: self.view) | |
let dropOperation: UIDropOperation? | |
if session.canLoadObjects(ofClass: String.self) { | |
if dropTextView.frame.contains(location) { | |
dropOperation = .copy | |
} else if dropImageView.frame.contains(location) { | |
dropOperation = .forbidden | |
} else { | |
dropOperation = .cancel | |
} | |
} | |
else if session.canLoadObjects(ofClass: UIImage.self) { | |
if dropImageView.frame.contains(location) { | |
dropOperation = .copy | |
} else if dropTextView.frame.contains(location) { | |
dropOperation = .forbidden | |
} else { | |
dropOperation = .cancel | |
} | |
} | |
else { | |
dropOperation = .cancel | |
} | |
return UIDropProposal(operation: dropOperation!) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment