用Instagram打开图像

Mc.*_*ver 6 iphone xcode objective-c ipad ios

嗨我需要在Instagram中导入我编辑过的图像,比如PhotoStudio:

在此输入图像描述

我使用以下代码捕获了我的图像:

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

    UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

然后我需要screenShot用Instagram 打开它:


编辑:

我实现这样的方法:

    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");
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个输出:

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.'
Run Code Online (Sandbox Code Playgroud)

Instagram将被打开,但不会导入任何东西.

sco*_*ord 1

你想要做的是打开一个特殊格式的网址。

这是我通过快速谷歌搜索找到的 instragram 文档:

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

这是描述url 方案过程的苹果文档。 http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007891-SW1