Note that there are some explanatory texts on larger screens.

plurals
  1. POExporting a photo to Instagram
    text
    copied!<p>I am trying to export a photo from my application to Instagram, using this code:</p> <pre><code>// Capture Screenshot UIGraphicsBeginImageContextWithOptions(self.view.frame.size,self.view.opaque,0.0); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData *imageData = UIImageJPEGRepresentation(image, 1.0); NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"]; NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]]; dic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:igImageHookFile]]; dic.UTI = @"com.instagram.photo"; dic.annotation = [NSDictionary dictionaryWithObject:@"my caption" forKey:@"InstagramCaption"]; NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { [[UIApplication sharedApplication] openURL:instagramURL]; } else { NSLog(@"No Instagram Found"); } </code></pre> <p>But it is not working. It crashes with the following error:</p> <blockquote> <p>2013-01-19 20:40:41.948 Ayat[12648:c07] <strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> -[NSURL initFileURLWithPath:]: nil string parameter'</p> </blockquote> <p>I am not sure I'm properly:</p> <p>1- Saving jpgpath as the screenshot I took .</p> <p>2- Passing the "dic" document to Instagram.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload