我正在使用以下Instagram挂钩将图片发布到Instagram。在iOS 8中,Instagram应用程序在UIDocumentInteractionController中单独显示,但在iOS 9中,它显示了其他选项。任何人都知道为什么会这样,以及如何解决这个问题,以便只有Instagram再次显示?
UIImage *screenShot = self.shareableImage.image;
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.ig"];
[UIImagePNGRepresentation(screenShot) writeToFile:savePath atomically:YES];
CGRect rect = CGRectMake(0 ,0 , 0, 0);
NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=MEDIA_ID"];
NSString *documentDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
// *.igo is exclusive to instagram
NSString *saveImagePath = [documentDirectory stringByAppendingPathComponent:@"Image.igo"];
NSData *imageData = UIImagePNGRepresentation(screenShot);
[imageData writeToFile:saveImagePath atomically:YES];
NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
self.dic=[[UIDocumentInteractionController alloc]init];
self.dic.delegate=self;
self.dic.UTI=@"com.instagram.photo";
[self.dic setURL:imageURL];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"imageShareViewNoInstagramAccountAlertTitle", nil)] message:[NSString stringWithFormat:NSLocalizedString(@"imageShareViewNoInstagramAccountAlertMessage", nil)]delegate:nil cancelButtonTitle:[NSString stringWithFormat:NSLocalizedString(@"imageShareViewNoFacebookAccountAlertCancelButton", nil)]otherButtonTitles:nil, nil];
[alert show];
}
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate
{
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
答案 0 :(得分:0)
尝试将com.instagram.photo
更改为com.instagram.exclusivegram
。
干杯!