UIDocumentInteractionController通过Instagram分享(仅限Instagram)

Alb*_*haw 5 objective-c uti ios instagram uidocument

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


有什么方法我可以让它只提供在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];
Run Code Online (Sandbox Code Playgroud)

Alb*_*haw 11

原来让doc控制器只在Instagram中打开你只需保存你的png或jpg文件格式为".igo"文件类型扩展名,(也许代表Instagram-Only?)



改变了我的代码中的第三行代码来读取相反:

NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];
Run Code Online (Sandbox Code Playgroud)

(用"igo")



然后它工作了!:)

  • 似乎Dropbox的优秀人员决定在他们的应用程序中包含.igo文件,谁知道是什么原因,所以现在他们已经打破了其他人的仅限Instagram的功能.#ThanksDropBox (6认同)
  • @DevC我不认为这是iOS9的东西,我认为其他一些应用程序开始适应.igo,以便在搜索该文件格式时可以显示它们.如果你问我,这是一种非常蹩脚和侵略性的策略. (3认同)