在 iOS 中与 Instagram 上的图像共享文本

Posted

技术标签:

【中文标题】在 iOS 中与 Instagram 上的图像共享文本【英文标题】:Share text with Images on Instagram in ios 【发布时间】:2013-04-02 10:35:58 【问题描述】:

在我的应用程序中,我在 Instagram 上分享了一张图片。它在我的应用中运行良好。

我正在使用以下代码。

@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]];
//    NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", screenshot]];

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 以共享图像,它运行良好。

但是我可以检查用户是否已成功共享它吗?

意味着当用户成功共享图像时,我想在我的数据库中执行一些操作。

我该怎么做?

【问题讨论】:

【参考方案1】:

我得到了答案。刚刚添加了一行,它对我有用。

self.dic.annotation = [NSDictionary dictionaryWithObject:@"Here Give what you want to share" forKey:@"InstagramCaption"];

谢谢...

【讨论】:

添加文本和图像的任何其他设置..?【参考方案2】:

在http://instagram.com/developer/iphone-hooks/的官方文档中也有记录

要在您的照片中包含预填充的标题,您可以将文档交互请求中的注释属性设置为包含键“InstagramCaption”下的 NSString 的 NSDictionary。注意:此功能将在 Instagram 2.1 及更高版本上可用。

【讨论】:

自 2015 年 8 月起,Instagram 将忽略 InstagramCaption 注释。见:developers.instagram.com/post/125972775561/…【参考方案3】:

您不能再与 Instagram 或 Facebook 共享预填充文本。

只有图像/屏幕截图可以通过 UIDocumentInteractionController 共享。

【讨论】:

以上是关于在 iOS 中与 Instagram 上的图像共享文本的主要内容,如果未能解决你的问题,请参考以下文章

分享后如何从 Instagram 应用重定向到我的 iOS 应用

Instagram ios14故事分享黑屏

与 Instagram、Facebook 共享相机胶卷中的图像

用于发布视频的 Instagram iOS API [关闭]

使用android意图将带有图像的文本共享到instagram

使用意图的 Android 6.0 instagram 图像共享不起作用