Created
January 18, 2017 06:22
-
-
Save leoiphonedev/192fbe158250267ce1192e87c9fd40b0 to your computer and use it in GitHub Desktop.
UIDocumentInteractionController tutorial for sharing image
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
UIImage *instaImage = [UIImage imageNamed:@"imageToShare.png"]; | |
NSString* imagePath = [NSString stringWithFormat:@"%@/image.png",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]]; | |
[[NSFileManager defaultManager] removeItemAtPath:imagePath error:nil]; | |
[UIImagePNGRepresentation(instaImage) writeToFile:imagePath atomically:YES]; | |
self._docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:imagePath]]; | |
[self._docController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment