Last active
April 11, 2018 17:28
-
-
Save leoiphonedev/4720f6e0c71c307415c754d13e6a442e to your computer and use it in GitHub Desktop.
Sharing image to Instagram using Swift language
This file contains 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
let image = UIImage(named: "imageToShare") | |
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String | |
let checkValidation = FileManager.default | |
let getImagePath = paths.appending("image.igo") | |
try? checkValidation.removeItem(atPath: getImagePath) | |
let imageData = UIImageJPEGRepresentation(image!, 1.0) | |
try? imageData?.write(to: URL.init(fileURLWithPath: getImagePath), options: .atomicWrite) | |
var documentController : UIDocumentInteractionController! | |
documentController = UIDocumentInteractionController.init(url: URL.init(fileURLWithPath: getImagePath)) | |
documentController.uti = "com.instagram.exclusivegram" | |
documentController.presentOptionsMenu(from:self.view.frame, in: self.view, animated: true) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment