I was a little obsessed with trying out different Photo Captioning apps for a while, until I finally settled on Typic, and then deleted the rest.
What does apps (Overgram, Instaquote and Typic) had in common was that at the end of the day, they all let you share your work in Instagram.
I’m just gonna write a really short code bit on how to do that.
Instagram allows apps to interact with their using different iPhone hooks (http://instagram.com/developer/iphone-hooks).
I’m going to use Document Interaction API.
It’s pretty simple, according to the Instagram developer page, you’d need to save your picture with a “.ig” or a “.igo” extension. And it has to be at least 612 pixels, either in width or height, anything less, won’t be accepted by Instagram.
When your picture is opened in Instagram, it’ll go automatically to the Filter screen. That means there’s no crop option, so better if your picture is a square.
So code bits:
In the .h of your ViewController, declare a UIDocumentInteractionController:
@property (strong, nonatomic) UIDocumentInteractionController *documentInteractionController;
And then set it as a UIDocumentInteractionControllerDelegate, like this:
@interface ComicViewController : UIViewController <UIDocumentInteractionControllerDelegate>
And then in the .m of your View Controller you add a button, or whatever that you want to use to trigger “Open in Instagram” that calls this method:
NSString *strImagePath = [[NSHomeDirectory() stringByAppendingPathComponent:@”Documents”] stringByAppendingPathComponent: filename];
NSURL *url = [NSURL fileURLWithPath: strImagePath];
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL: url];
NSMutableDictionary *annotationDict = [[NSMutableDictionary alloc] init];
[annotationDict setValue: @”Instagram Caption” forKey: @”InstagramCaption”];
self.documentInteractionController.UTI = @”com.instagram.photo”;
self.documentInteractionController.annotation = [[NSDictionary alloc] initWithDictionary: annotationDict];
[self.documentInteractionController presentOpenInMenuFromRect: CGRectZero inView: self.view animated: YES];
You need to pass an url to your Document Interaction Controller, since my file is saved in the Documents folder of my app, so my url looks like that.
So if you want to open your picture in Instagram and any other app that supports opening image files, simply use the file extension “.ig” for your image, but if you only want to open in Instragram, use “.igo”. Also, the UTI I set in the code above is “com.instagram.photo”, if you want it to be exclusive, use “com.instagram.exclusivegram”
You can set the caption you want to appear in Instagram. You can add hash tags in your caption, that works too.
And that’s it, when you click a button that calls the “openInInstagram” method, you’ll be able to see an action sheet similar to that screenshot.