在ios上与Instagram上的图像共享文本

时间:2013-04-02 10:35:58

标签: iphone ios objective-c instagram

在我的应用程序中,我在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以共享图像,它工作正常。

但我是否有可能检查用户是否已成功共享?

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

我该怎么做?

3 个答案:

答案 0 :(得分:14)

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

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

...谢谢

答案 1 :(得分:3)

http://instagram.com/developer/iphone-hooks/

的官方文档中也记录了这一点
  

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

答案 2 :(得分:2)

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

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