当我使用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“
我的代码:
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];

发布于 2014-11-09 21:18:37
原来,要使doc控制器只在Instagram中打开,只需保存png或jpg文件格式的".igo“文件类型扩展名,(可能代表Instagram?)
将代码中的第三行代码改为:
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];(加上"igo")
然后成功了!)
发布于 2020-03-09 10:14:50
iOS 13的较低版本:
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];在iOS 13之后:
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.ig"];https://stackoverflow.com/questions/26833348
复制相似问题