首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIDocumentInteractionController通过Instagram分享(而且只有Instagram)

UIDocumentInteractionController通过Instagram分享(而且只有Instagram)
EN

Stack Overflow用户
提问于 2014-11-09 21:06:37
回答 2查看 6.1K关注 0票数 5

当我使用UIDocumentInteractionController允许用户通过Instagram分享时,它确实有效,它会将"open“和"Instagram”选项作为选项之一.问题是,它还显示了许多其他应用,如"Facebook“和”Twitter“.

有没有办法让它只允许在instagram应用程序中打开?

Instagram声称有一种方法可以做到这一点:http://instagram.com/developer/iphone-hooks/,但他们提到:

"Alternatively, if you want to show only Instagram in the application list (instead of Instagram plus any other public/jpeg-conforming apps) you can specify the extension class igo, which is of type com.instagram.exclusivegram."

但我真的不知道这部分是什么意思,"extension class igo

我的代码:

代码语言:javascript
复制
UIImage *imageToUse = [UIImage imageNamed:@"imageToShare.png"];
NSString *documentDirectory=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.ig"];
NSData *imageData=UIImagePNGRepresentation(imageToUse);
[imageData writeToFile:saveImagePath atomically:YES];
NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
docController = [UIDocumentInteractionController interactionControllerWithURL:imageURL];
docController.delegate = self;
docController.annotation = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"This is the users caption that will be displayed in Instagram"], @"InstagramCaption", nil];
docController.UTI = @"com.instagram.exclusivegram";
[docController presentOpenInMenuFromRect:CGRectMake(1, 1, 1, 1) inView:self.view animated:YES];

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-11-09 21:18:37

原来,要使doc控制器只在Instagram中打开,只需保存png或jpg文件格式的".igo“文件类型扩展名,(可能代表Instagram?)

将代码中的第三行代码改为:

代码语言:javascript
复制
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];

(加上"igo")

然后成功了!)

票数 11
EN

Stack Overflow用户

发布于 2020-03-09 10:14:50

iOS 13的较低版本:

代码语言:javascript
复制
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];

在iOS 13之后:

代码语言:javascript
复制
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.ig"];
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26833348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档