Instagram - share image, text and url via iOS app : swift
Instagram had removed pushing custom captions to their app while sharing photos at one point, check this post.
I also understand, according to the Instagram iPhone Hooks page, that you can pass a photo only to the "Select A Filter" Instagram screen, which is before you set a caption. I'm sorry, but I don't think Instagram supports custom captions.
How to share an image on Instagram in iOS?
Finally I got the answer. you can not directly post an image on instagram. You have to rediredt your image with UIDocumentInteractionController.
@property (nonatomic, retain) UIDocumentInteractionController *dic;
CGRect rect = CGRectMake(0 ,0 , 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
NOTE : once you redirect to instagram app you can not back to your app. you have to open your app again
Download source from here
Related Topics
Issue with Auto Layout on iOS 8 (Code Works Perfectly on iOS 7)
Swift - Coredata Migration - Set New Attribute Value According to Old Attribute Value
iOS Glsl. How to Create an Image Histogram Using a Glsl Shader
Number of Days in the Current Month Using iOS
Crashlytics iOS - Log Caught Exception
Setting Maximum Number of Characters of 'Uitextview ' and 'Uitextfield '
Perform Push Segue After an Unwind Segue
Loading a Resource (E.G. Storyboard) in a Swift Framework
iOS Changing Uiscrollview Scrollbar Color to Different Colors
What Do JSONserialization Options Do and How Do They Change JSONresult
How to Stop Uitableview from Clipping Uitableviewcell Contents in iOS 7
Is There Function to Convert Uicolor to Hue Saturation Brightness
Mapkit iOS 9 Detailcalloutaccessoryview Usage
How to Make Uiimageview Automatically Resize to the Size of the Image Loaded
How to Move Cursor from One Text Field to Another Automatically in Swift iOS Programmatically
How to Detect Call Incoming Programmatically
How to Access Swift 4 Class from Objective-C: "Property Not Found on Object of Type"