【问题标题】:Open image with Instagram使用 Instagram 打开图像
【发布时间】:2012-05-05 16:45:59
【问题描述】:

您好,我需要在 Instagram 中导入我编辑的图像,例如 PhotoStudio:

我用这段代码捕获了我的图像:

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

    UIGraphicsEndImageContext();

然后我需要用 Instagram 打开这个screenShot


已编辑

我实现了这样的方法:

    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");
    }
}

但我收到了这个输出:

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 将打开,但不会导入任何内容。

【问题讨论】:

标签: iphone objective-c ios xcode ipad


【解决方案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

【讨论】:

  • 问题在于您如何设置文档 ID。您正在将 ID 设置为“屏幕截图”。但屏幕截图是 UIImage。弄清楚如何获取图像 ID,然后使用它。
【解决方案2】:

要在 Instagram 上分享图片,图片的最小尺寸应为 612x612。否则它不会导入图像。

【讨论】:

    猜你喜欢
    • 2015-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多