Skip to content

Instantly share code, notes, and snippets.

@luispedrofonseca
Created June 18, 2014 16:22
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 luispedrofonseca/74e1ac65da03f335a8a2 to your computer and use it in GitHub Desktop.
Save luispedrofonseca/74e1ac65da03f335a8a2 to your computer and use it in GitHub Desktop.
NSURL *appURL = [NSURL URLWithString:@"instagram://app"];
if([[UIApplication sharedApplication] canOpenURL:appURL])
{
// Image
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
// Post
[UIImageJPEGRepresentation(image, 1.0) writeToFile:[self photoFilePath] atomically:YES];
NSURL *fileURL = [NSURL fileURLWithPath:[self photoFilePath]];
self.dic = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
self.dic.UTI = @"com.instagram.exclusivegram";
self.dic.delegate = self;
if (message)
self.dic.annotation = [NSDictionary dictionaryWithObject:message forKey:@"InstagramCaption"];
[self.dic presentOpenInMenuFromRect:CGRectZero inView:nativeWindow.rootViewController.view animated:YES];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment