Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoiphonedev/192fbe158250267ce1192e87c9fd40b0 to your computer and use it in GitHub Desktop.
Save leoiphonedev/192fbe158250267ce1192e87c9fd40b0 to your computer and use it in GitHub Desktop.
UIDocumentInteractionController tutorial for sharing image
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