Created
July 24, 2016 06:11
Revisions
-
maximbilan revised this gist
Jul 24, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,5 +20,5 @@ if UIApplication.sharedApplication().canOpenURL(instagramURL!) { } } else { print("Instagram not found") } -
maximbilan created this gist
Jul 24, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ let image = UIImage(named: "example") let instagramURL = NSURL(string: "instagram://app") if UIApplication.sharedApplication().canOpenURL(instagramURL!) { let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] let saveImagePath = (documentsPath as NSString).stringByAppendingPathComponent("Image.igo") let imageData = UIImagePNGRepresentation(image!) do { try imageData?.writeToFile(saveImagePath, options: NSDataWritingOptions(rawValue: 0)) } catch { print("Instagram sharing error") } let imageURL = NSURL(fileURLWithPath: saveImagePath) documentInteractionController.URL = imageURL documentInteractionController.annotation = ["InstagramCaption" : "Testing"] documentInteractionController.UTI = "com.instagram.exclusivegram" let bounds = someButton.bounds if !documentInteractionController.presentOpenInMenuFromRect(bounds, inView: self.view, animated: true) { print("Instagram not found") } } else { print("Instagram not found") }