I'm using the following Instagram hook to post an image to Instagram. In iOS 8, the Instagram app was showing by itself in the UIDocumentInteractionController, but in iOS 9 it shows other options alongside it. Anyone know why this may be and how to resolve this so that only Instagram shows again?
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;
}