Created
December 9, 2015 14:40
-
-
Save anvarazizov/ae47502ca9964955ddaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)shareImageToInstagram:(UIImage *)image inView:(UIView *)view | |
{ | |
NSURL * instagramURL = [NSURL URLWithString:@"instagram://"]; | |
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) | |
{ | |
NSString * documentDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; | |
NSString * saveImagePath = [documentDirectory stringByAppendingPathComponent:@"Image.igo"]; | |
NSData * imageData = UIImagePNGRepresentation(image); | |
[imageData writeToFile:saveImagePath atomically:YES]; | |
NSURL * imageURL = [NSURL fileURLWithPath:saveImagePath]; | |
self.docController = [UIDocumentInteractionController interactionControllerWithURL:imageURL]; | |
self.docController.delegate = self; | |
self.docController.UTI = kInstagramUTI; | |
[self.docController presentOpenInMenuFromRect:CGRectMake(1, 1, 1, 1) inView:view animated:YES]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment