繁体   English   中英

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

[英]Share text with Images on Instagram in ios

在我的应用程序中,我在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,以共享图像,并且效果很好。

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

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

我怎样才能做到这一点?

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

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

谢谢...

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

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

您不再被允许与Instagram或Facebook分享预填文本。

只能通过UIDocumentInteractionController共享图像/屏幕截图。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM