2013-04-02 46 views
7

在我的应用程序中,我在Instagram上分享图像。它在我的应用程序中运行良好。在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; 
} 

现在我还想分享一些文字与图像。

如下图所示。在“编写标题”中,我想为例如一些默认的自定义文本。 “分享这张照片”。

我该怎么做?

在此先感谢...

enter image description here

编辑

我从我的应用程序打开Instagram的分享图像,它工作正常。

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

表示我想在用户成功分享图像时在我的数据库中执行某些操作。

我该怎么做?

回答

14

我得到了我的答案。只是添加了一条线,它为我工作。

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

谢谢...

+0

嘿,这不适合我。 –

+0

添加文本和图像的任何其他设置..? –

3

它还在http://instagram.com/developer/iphone-hooks/

记录的官方文档中包含有你的照片预填充的标题,你可以设置在注释属性文档交互请求到包含关键字“InstagramCaption”下的NSString的NSDictionary。注意:此功能将在Instagram 2.1及更高版本上提供。

+3

截至2015年8月,Instagram无视InstagramCaption注释。请参阅:http://developers.instagram.com/post/125972775561/removing-pre-filled-captions-from-mobile-sharing – joshrl

1

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

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

相关问题