6

Hi I need to import my edited image in Instagram , something like PhotoStudio :

enter image description here

I captured my image with this code :

    UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0);
    [self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

Then I need to open this screenShot with Instagram:


EDITED:

I implement the method like this :

    UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0);
    [self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", screenshot]];

    docFile.UTI = @"com.instagram.photo";
    [self setupDocumentControllerWithURL:igImageHookFile];

    NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=MEDIA_ID"];
    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
        [[UIApplication sharedApplication] openURL:instagramURL];
    }

    else {   
        NSLog(@"No Instagram Found");
    }
}

But I receive this output :

2012-05-05 21:55:36.842 InstantFrame[855:707] *** Assertion failure in -[UIDocumentInteractionController setURL:], /SourceCache/UIKit/UIKit-1914.84/UIDocumentInteractionController.m:1094
2012-05-05 21:55:36.848 InstantFrame[855:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIDocumentInteractionController: invalid scheme (null).  Only the file scheme is supported.'

Instagram will be opened but does not import anything.

Perception
  • 79,279
  • 19
  • 185
  • 195
iOS.Lover
  • 5,923
  • 21
  • 90
  • 162
  • 1
    See this question: http://stackoverflow.com/questions/8302593/iphone-open-in-in-sdk – Jonathan May 05 '12 at 16:52
  • have you done the instagram? plz share with me instagram part – Hiren Jul 10 '12 at 13:42
  • Also try this answer: http://stackoverflow.com/a/5631674/2284713 Using [NSURL fileURLWithPath:urPath] for igImageHookFile worked for me. – weienw Mar 28 '14 at 18:25

2 Answers2

1

What you want to do is open a specially formatted url.

Here is the instragram documentation i found with a quick google search:

http://instagr.am/developer/iphone-hooks/

Here is the apple docs that describes the url scheme process. http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007891-SW1

scord
  • 1,375
  • 1
  • 17
  • 34
  • The problem is how you are setting the document ID. You are setting the ID to "screenshot". But screen shot is an UIImage. Figure out how to get an Image ID then use that. – scord May 05 '12 at 19:46
0

To share image on Instagram, minimum size of image should be 612x612. Other wise it does not import image.

Ashish Chauhan
  • 1,316
  • 15
  • 22