in my application I manage to post an image to Instagram through a Document Interaction Controller. This one shows also options for sharing on Dropbox, whatsapp, etc.. I don't want these features, I just want Instagram. Is there a way to programmatically click on Instagram button, or to remove other unwanted applications' buttons? Thank you in advance for your answers.
EDIT: Here is the code, with the line containing "com.instagram.exclusivegram" I managed to show only Instagram, Bump and Dropbox. How can I make the last two disappear?
-(void)ShareInstagram
{
[self storeimage];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
CGRect rect = CGRectMake(0 ,0 , 612, 612);
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/15717.igo"];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];
_dic.UTI = @"com.instagram.exclusivegram";
_dic.delegate=self;
_dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
_dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
_dic.delegate=self;
[_dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
// [[UIApplication sharedApplication] openURL:instagramURL];
}
else
{
// NSLog(@"instagramImageShare");
UIAlertView *errorToShare = [[UIAlertView alloc] initWithTitle:@"Instagram unavailable " message:@"You need to install Instagram in your device in order to share this image" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
errorToShare.tag=3010;
[errorToShare show];
}
}
- (void) storeimage
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"15717.igo"];
UIImage *NewImg=[self resizedImage:_imageToTweet inImage:CGRectMake(0, 0, 612, 612) ];
NSData *imageData = UIImagePNGRepresentation(NewImg);
[imageData writeToFile:savedImagePath atomically:NO];
}
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate
{
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
interactionController.delegate = self;
return interactionController;
}