ios - UIDocumentInteractionController 通过 Instagram 分享(且仅限 Instagram)

标签 ios objective-c instagram uidocument uti

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


有什么办法可以让它只提供在 Instagram 应用程序中打开的选项吗?


Instagram 声称有一种方法可以做到这一点:http://instagram.com/developer/iphone-hooks/但他们提到这个:
“或者,如果您只想在应用程序列表中显示 Instagram(而不是 Instagram 以及任何其他符合公共(public)/jpeg 标准的应用程序),您可以指定扩展类 igo,其类型为 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];

最佳答案

事实证明,要让文档 Controller 仅在 Instagram 中打开,您只需将 png 或 jpg 文件保存为“.igo”文件类型扩展名格式,(也许代表 Instagram-Only?)



更改了我的代码中的第三行代码以改为阅读:

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

(带有“igo”)



然后成功了! :)

关于ios - UIDocumentInteractionController 通过 Instagram 分享(且仅限 Instagram),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26833348/

相关文章:

ios - 使用 AFNetworking 在 objective-c 中的模型对象内部获取远程数据

objective-c - 使用两个 NSDate 计算一个人的年龄

ruby-on-rails - 503 : Instagram is rate limiting your requests

ios - 自定义 Instagram 登录 View

objective-c - 异步 setUp 方法完成后运行测试

android - 如何使用 instagram 直接 api

iphone - 禁用特定类的 NSLog

ios - 何时使用 AVAudioPlayer 方法 prepareToPlay()

ios - UITableViewController 静态单元格在推送到 navigationController 时不出现

objective-c - 指针在 Objective-C 中是如何工作的