Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:44:07+00:00 2026-06-18T06:44:07+00:00

I used following code but it didn’t work. I want to put an image

  • 0

I used following code but it didn’t work.
I want to put an image from my application to Instagram app installed on my iPhone..

NSString *fileToOpen = [[NSBundle mainBundle] pathForResource:@"IMG_0192"  ofType:@"jpg"];
fileToOpen = [fileToOpen substringToIndex:[fileToOpen length] - 3];
fileToOpen=[NSString stringWithFormat:@"%@ig",fileToOpen];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
NSLog(@"%@",fileToOpen);
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
//imageToUpload is a file path with .ig file extension
/*UIAlertView *alert = [[UIAlertView alloc] 
                      initWithTitle:@"" 
                      message:@"Can open app!" 
                      delegate:self  
                      cancelButtonTitle:@"OK" 
                      otherButtonTitles:nil];
[alert show];
*/

self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileToOpen]];
self.documentInteractionController.UTI = @"com.instagram.photo";
self.documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"Its a testing" forKey:@"InstagramCaption"];

I tried a lot but it’s not working at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:44:08+00:00Added an answer on June 18, 2026 at 6:44 am

    You can use following code to share image from your app to Instagram app installed on your iPhone.

    - (void) shareImageToInstagram 
    {
        NSURL *instagramURL = [NSURL URLWithString:@"instagram://"];
        if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) 
        {
            CGRect rect = CGRectMake(0,0,0,0);
            CGRect cropRect=CGRectMake(0,0,612,612);
            NSString *jpgPath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"];
            CGImageRef imageRef = CGImageCreateWithImageInRect([imgViewPost.image CGImage], cropRect);
            UIImage *img = [[UIImage alloc] initWithCGImage:imageRef];
            CGImageRelease(imageRef);
    
            [UIImageJPEGRepresentation(img, 1.0) writeToFile:jpgPath atomically:YES];
            NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@",jpgPath]];
            self.dicont.UTI = @"com.instagram.photo";
            self.dicont = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
            self.dicont.annotation = [NSDictionary dictionaryWithObject:@"Your AppName" forKey:@"InstagramCaption"];
            [self.dicont presentOpenInMenuFromRect: rect  inView: self.view animated: YES ];
        }
        else
        {
            DisplayAlert(@"Instagram not installed in this device!\nTo share image please install instagram.");
        }
    }
    
    - (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
        UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
        interactionController.delegate = interactionDelegate;
    
        return interactionController;
    }
    

    Please try this code..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used the following code to download/save an image and open it later, but
I swear the following code used to work, even in IE7 but now i
The following source code are used to implement product/consumer pattern, but they don't work
I used following code but I didn't get output. SqlDataAdapter da = new SqlDataAdapter(select
I am trying to used following code but I am not getting good performance
I used following code, but it displays only 2 digit of ISO country name.
In the following code DEFAULT_CACHE_SIZE is declared later, but it is used to assign
I have used following code to convert string to json and parse it. String
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have used following code to create a simple PDF file. It executes fine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.