如何在iOS上分享Instagram上的图像? [英] How to share an image on Instagram in iOS?

查看:160
本文介绍了如何在iOS上分享Instagram上的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户希望在Instagram,Twitter,Facebook上分享图片。

My client wants to share an image on Instagram, Twitter, Facebook.

我已经完成了Twitter和Facebook,但没有在互联网上找到任何API或任何东西在Instagram上分享图片。 可以在Instagram上分享图片吗?如果是,那么如何?

I have done Twitter and Facebook but did not find any API or any thing on internet to share image on Instagram. Is it possible to share image on Instagram? if yes then how?

当我查看Instagram的开发者网站时,我找到了Ruby on Rails和Python的库。但是没有iOS Sdk的文档

When I check the developer site of Instagram I have found the Libraries of Ruby on Rails and Python. But there are no documentation of iOS Sdk

我已根据instagram.com/developer从Instagram获取令牌,但现在不知道下一步要与共享做什么Instagram图片。

I have get token from instagram as per instagram.com/developer but now don't know what to do next step for sharing with instagram image.

推荐答案

最后我得到了答案。你不能直接在Instagram上发布图像。您必须使用UIDocumentInteractionController重新编写图像。

Finally I got the answer. you can not directly post an image on instagram. You have to rediredt your image with UIDocumentInteractionController.

@property (nonatomic, retain) UIDocumentInteractionController *dic;    

CGRect rect = CGRectMake(0 ,0 , 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"];

NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[self.dic presentOpenInMenuFromRect: rect    inView: self.view animated: YES ];


- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
     UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
     interactionController.delegate = interactionDelegate;
     return interactionController;
}

注意:一旦你重定向到Instagram app你无法返回您的应用。你必须再次打开你的应用程序

NOTE : once you redirect to instagram app you can not back to your app. you have to open your app again

这里下载源代码

这篇关于如何在iOS上分享Instagram上的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆