用Instagram打开图片

6

你好,我需要将编辑过的图片导入到Instagram中,就像PhotoStudio一样:

enter image description here

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

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


1
请查看此问题:https://dev59.com/Ll3Va4cB1Zd3GeqPDLlx - Jonathan
你做完Instagram了吗?请与我分享Instagram部分。 - Hiren
还可以尝试这个答案:https://dev59.com/T2445IYBdhLWcg3w3N-z#5631674 对于 igImageHookFile,使用 [NSURL fileURLWithPath:urPath] 对我很有效。 - weienw
2个回答

1

问题在于你如何设置文档ID。你将ID设置为“screenshot”。但是截图是UIImage。找出如何获取图像ID,然后使用它。 - scord

0
分享图片到Instagram,图片的最小尺寸应为612x612。否则,它将无法导入图片。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接