使用UIDocumentInteractionController在IOS 9中打开Instagram

时间:2015-10-12 09:03:19

标签: ios instagram ios9

嗨,这是我直接用图片打开Instagram App的代码。正如Apple文档中关于UIDocumentInteractionController和Instagram钩子页面中所述,这段代码应该直接用图像打开instagram,但是在所有测试条件下它都会打开操作表,所有应用程序都与保存的扩展名兼容。

我还在LSApplicationQueriesSchemes中将Instagram列入白名单。

我怎样才能获得这个结果?这是IOS 9的错误或新的安全功能吗?

提前感谢您的帮助

NSURL *instagramURL = [NSURL URLWithString:@"instagram:/"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.ig"];
[UIImagePNGRepresentation(capturedImage) writeToFile:getImagePath atomically:YES];
NSURL *imageFileURL =[NSURL fileURLWithPath:getImagePath];
NSLog(@"imag %@",imageFileURL);

self.dic.delegate = self;
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:imageFileURL usingDelegate:self];
[self.dic presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

} else  //prompt for app missing


- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL
                                           usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate { 
UIDocumentInteractionController *interactionController =
[UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}

1 个答案:

答案 0 :(得分:2)

如果您将图片保存为.igo,我在动态表中看到的唯一应用就是&#34; Instagram&#34; &#34;注释&#34;和&#34;其他。

编辑:我找不到直接用图片打开Instagram的方法,似乎只能用

直接打开它
NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    [[UIApplication sharedApplication] openURL:instagramURL];
}

但您无法使用

添加图片

edit2:我忘了添加.igo格式,你需要使用self.dic.UTI = "com.instagram.exclusivegram"