I need to be able to share photos on Instagram as well as also to all the options that are presented with UIActivityViewController
- Facebook, Twitter, mail, etc. I manage to share to Instagram with UIDocumentInteractionController
, but need to have all the options at one place. I added custom UIActivity
to the UIActivityViewController
activities, but don't know how to proceed directly to Instagram from there. Now it just options similar menu with the Instagram option, because I present a UIDocumentInteractionController
. Is there a way to have all options at one menu?
Thanks to: Sharing image to Whatsapp & Facebook accepted response.
It looks that this option is actually provided out of the box for UIDocumentInteractionController
, but I was presenting the controller wrongly. The correct way to display all options is to use: -presentOptionsMenuFromRect:inView:animated:
instead of -presentOpenInMenuFromRect:inView:animated:
The UIDocumentInteractionController
does not allow to omit some of the options like UIActivityViewController
does, but I need to have Instagram alongside the other options, so this is the way to go.
The code I use:
NSString *documentDirectory=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"MyImage.png"];
NSData *imageData=UIImagePNGRepresentation(imageToUse);
[imageData writeToFile:saveImagePath atomically:YES];
NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
docIntController = [UIDocumentInteractionController interactionControllerWithURL:imageURL];
docIntController.delegate = self;
[docIntController presentOptionsMenuFromRect:CGRectMake(1, 1, 1, 1) inView:self.view animated:YES];