xcode 使用 Instagram 打开图片

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10463911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:11:59  来源:igfitidea点击:

Open image with Instagram

iphoneobjective-ciosxcodeipad

提问by Mc.Lover

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

嗨,我需要在 Instagram 中导入我编辑过的图像,例如 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 screenShotwith Instagram:

然后我需要screenShot用 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.

Instagram 将被打开,但不会导入任何内容。

采纳答案by scord

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

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

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

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

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

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

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

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

回答by Ashish Chauhan

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

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