Last active
July 12, 2017 10:57
-
-
Save leoiphonedev/ee1ff232b2fecae54109af51d7cb6ff9 to your computer and use it in GitHub Desktop.
Share image to instagram using objective C in iOS app development
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
UIImage *instaImage = [UIImage imageNamed:@"imagetoShare.png"]; | |
NSString* imagePath = [NSString stringWithFormat:@"%@/image.igo",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, | |
NSUserDomainMask, YES) lastObject]]; | |
[[NSFileManager defaultManager] removeItemAtPath:imagePath error:nil]; | |
[UIImagePNGRepresentation(instaImage) writeToFile:imagePath atomically:YES]; | |
UIDocumentInteractionController *_docController = [UIDocumentInteractionController interactionControllerWithURL: | |
[NSURL fileURLWithPath:imagePath]]; | |
_docController.UTI = @"com.instagram.exclusivegram"; | |
[_docController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this code show error - *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIDocumentInteractionController has gone away prematurely!'