Ios Instagram hook com.Instagram.exclusivegram并非如此排他性
据我所知,如果您真的只希望instagram+使用正确的扩展名.ig,则必须使用com.instagram.photo来获取documentinteractioncontroller的UTI的常规选项和com.instagram.exclusivegram 出于某种原因,我看到了多种选择,而不仅仅是我想要的Instagram 我忘了什么吗?有不同的做法吗Ios Instagram hook com.Instagram.exclusivegram并非如此排他性,ios,api,hook,instagram,Ios,Api,Hook,Instagram,据我所知,如果您真的只希望instagram+使用正确的扩展名.ig,则必须使用com.instagram.photo来获取documentinteractioncontroller的UTI的常规选项和com.instagram.exclusivegram 出于某种原因,我看到了多种选择,而不仅仅是我想要的Instagram 我忘了什么吗?有不同的做法吗 UIImage *image = (UIImage *)[info valueForKey:UIImagePickerControllerOr
UIImage *image = (UIImage *)[info valueForKey:UIImagePickerControllerOriginalImage];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
CGRect rect = CGRectMake(0,0,0,0);
CGRect cropRect=CGRectMake(0,0,612,612);
// ig voor gewone instagram, igo voor exclusive instagram
NSString *jpgPath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/temp/photo.igo"];
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], cropRect);
UIImage *img = [[UIImage alloc] initWithCGImage:imageRef];
CGImageRelease(imageRef);
[UIImageJPEGRepresentation(img, 1.0) writeToFile:jpgPath atomically:YES];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@",jpgPath]];
// exclusive zou direct in de instagram app moeten openen, helaas toont hij meerdere opties met instagram ergenes helemaal achteraan
self.documentInteractionController.UTI = @"com.instagram.exclusivegram";
self.documentInteractionController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"Alweer een Nostalgie deelnemer! #nostalgiebusje" forKey:@"InstagramCaption"];
[self.documentInteractionController presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
}
似乎UTI字符串被URL:usingDelegate:方法的SetupController覆盖。您需要创建一个带有“ig”或“igo”扩展名的临时图像副本,然后与UTI“com.instagram.exclusivegram”共享。这应该只为DocumentInteractionController提供Instagram选项:
if (![fm fileExistsAtPath:tempDirectory])
[fm createDirectoryAtPath:tempDirectory withIntermediateDirectories:YES attributes:nil error:nil];
NSString *tempInstagramPath = [tempDirectory stringByAppendingPathComponent:@"instagramShare.igo"];
if ([fm fileExistsAtPath:tempInstagramPath])
[fm removeItemAtPath:tempInstagramPath error:nil];
[UIImageJPEGRepresentation(imageToShare, 1.0) writeToFile:tempInstagramPath atomically:NO];
documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:tempInstagramPath]];
documentInteractionController.delegate = self;
documentInteractionController.UTI = @"com.instagram.exclusivegram";
documentInteractionController.annotation = @{@"InstagramCaption": @"My Photo Caption!"};
if (![documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated:YES])
NSLog(@"Cannot open Document Interaction Controller for sharing with Instagram");
使用文件扩展名
igo
是正确的,并且列表中显示的应用程序数量比使用ig
时要少得多。从我的测试(仅限iOS 9)来看,UTI对显示的列表没有影响
看起来已过时。我也有同样的问题…请使用URL:usingDelegate:方法发布您的
设置控制器。设置UTI
字符串后,此方法的结果将分配给documentInteractionController
属性。
if (![fm fileExistsAtPath:tempDirectory])
[fm createDirectoryAtPath:tempDirectory withIntermediateDirectories:YES attributes:nil error:nil];
NSString *tempInstagramPath = [tempDirectory stringByAppendingPathComponent:@"instagramShare.igo"];
if ([fm fileExistsAtPath:tempInstagramPath])
[fm removeItemAtPath:tempInstagramPath error:nil];
[UIImageJPEGRepresentation(imageToShare, 1.0) writeToFile:tempInstagramPath atomically:NO];
documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:tempInstagramPath]];
documentInteractionController.delegate = self;
documentInteractionController.UTI = @"com.instagram.exclusivegram";
documentInteractionController.annotation = @{@"InstagramCaption": @"My Photo Caption!"};
if (![documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated:YES])
NSLog(@"Cannot open Document Interaction Controller for sharing with Instagram");