当我使用 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/