Try this , In this code set your image in imgUpload object
- (IBAction)InstagramButtonClick
{
CGRect rect = CGRectMake(0.0, 0.0, 612, 612);
UIGraphicsBeginImageContext(rect.size);
[imgUpload drawInRect:rect];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"];
[UIImageJPEGRepresentation(img, 1.0) writeToFile:savePath atomically:YES];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", savePath]];
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
self.dic.annotation = [NSDictionary dictionaryWithObject:@"your message" forKey:@"InstagramCaption"];
[self.dic presentOpenInMenuFromRect: CGRectZero inView: self.view animated: YES ];
}
//Add the delegate UIDocumentInteractionControllerDelegate
and following is a delegate method
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}