【问题标题】:UIDocumentInteractionController share via Instagram (and ONLY Instagram)UIDocumentInteractionController 通过 Instagram 分享(并且仅限 Instagram)
【发布时间】:2014-11-09 21:06:37
【问题描述】:

当我使用UIDocumentInteractionController 允许用户通过 Instagram 分享时,它确实有效,它提供了“打开方式”和“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

我的代码:

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];

【问题讨论】:

  • 显示此错误 - *** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:UIDocumentInteractionController 过早地消失了! ios 10.3

标签: ios objective-c instagram uidocument uti


【解决方案1】:

结果是让 doc 控制器只在 Instagram 中打开,您只需将 png 或 jpg 文件保存为“.igo”文件类型扩展名格式,(也许代表 Instagram-Only?)



将我的代码中的第三行代码改为阅读:

NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];

(带“igo”)



然后它起作用了! :)

【讨论】:

  • 您知道如何删除带有 *.igo 文件的“保存到保管箱”选项吗?
  • 看来 Dropbox 的聪明人决定在他们的应用程序中包含 .igo 文件是出于什么原因,所以现在他们已经为其他所有人打破了仅限 instagram 的功能。 #ThanksDropBox
  • .igo 在 iOS9 中似乎不再工作,它仍然返回许多选项。
  • @DevC 我不认为这是 iOS9 的事情,我认为许多其他应用程序开始适应 .igo 以便当您搜索该文件格式时它们可以显示出来。如果你问我,这是一种非常蹩脚和侵入性的策略。
  • @DevC .igo 确实适用于 IOS9,使用 [documentController presentOpenInMenuFromRect] 而不是 [presentOptionsMenuFromRect:CGRectZero] - OpenIn 仅显示可以打开 .igo 的应用程序
【解决方案2】:

iOS 13 的低版本:

NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];

iOS 13 之后:

NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.ig"];

【讨论】:

  • 好一个!谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-24
相关资源
最近更新 更多