[英]Share text with Images on Instagram in ios
In my App I sharing an image on Instagram. 在我的应用程序中,我在Instagram上共享图像。 It is working well in my app.
在我的应用程序中运行良好。
I am using the following code. 我正在使用以下代码。
@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;
}
Now I also want to share some text with the image. 现在,我还想与图像共享一些文本。
As shown in the Image below. 如下图所示。 In " Write a Caption", I want some default custom text for eg.
在“写标题”中,我想要一些默认的自定义文本,例如。 "Share this photo".
“分享这张照片”。
How can I do this? 我怎样才能做到这一点?
Thanks in advance... 提前致谢...
Edited 已编辑
I am opening Instagram from my app for sharing images and it works fine. 我正在从我的应用程序中打开Instagram,以共享图像,并且效果很好。
But Is it possible that Can I check Whether the user has shared it successfully or not? 但是,是否可以检查用户是否已成功共享它?
Means I want to perform some action in my DB when user successfully shares an image. 意味着当用户成功共享图像时,我想在数据库中执行一些操作。
How can i do this? 我怎样才能做到这一点?
I got my answer. 我得到了答案。 Just added a line and it worked for me.
刚刚添加一行,它对我有用。
self.dic.annotation = [NSDictionary dictionaryWithObject:@"Here Give what you want to share" forKey:@"InstagramCaption"];
Thanks... 谢谢...
It is also documented in the official documentation at http://instagram.com/developer/iphone-hooks/ 它也记录在http://instagram.com/developer/iphone-hooks/的官方文档中
To include a pre-filled caption with your photo, you can set the annotation property on the document interaction request to an NSDictionary containing an NSString under the key "InstagramCaption".
要在照片中包含预填充的标题,可以在文档交互请求上将注释属性设置为NSDictionary,该NSDictionary在键“ InstagramCaption”下包含NSString。 Note: this feature will be available on Instagram 2.1 and later.
注意:此功能将在Instagram 2.1及更高版本上可用。
You are no more allowed to share Pre-Filled Text with Instagram or Facebook. 您不再被允许与Instagram或Facebook分享预填文本。
Only Images/Screenshots can be shared via UIDocumentInteractionController. 只能通过UIDocumentInteractionController共享图像/屏幕截图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.