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

查看:63
本文介绍了如何在 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 应用程序,您将无法返回到您的应用程序.你必须再次打开你的应用

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天全站免登陆