Image not instagram post from ios 6

I integrate Instagram into my application using instagram-ios-sdk . I can successfully login to Instagram and get the access token, but after that, when I try to send the image using the UIDocumentInteractionController from the UIImagePickerController , the image is not sent. The code for sending the image is shown below:

 (void)_startUpload:(UIImage *) image { NSLog(@"Image Object = %@",NSStringFromCGSize(image.size)); NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.igo"]; [UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES]; NSLog(@"file url %@",jpgPath); NSURL *igImageHookFile = [[NSURL alloc] init]; igImageHookFile = [NSURL fileURLWithPath:jpgPath]; NSLog(@"File Url = %@",igImageHookFile); documentInteractionController.UTI = @"com.instagram.photo"; [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile]; [self setupControllerWithURL:igImageHookFile usingDelegate:self]; [documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; } (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate { NSLog(@"%@",fileURL); UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL]; interactionController.delegate = interactionDelegate; return interactionController; } 

I converted the image to .ig format with a resolution of (612 * 612). But still the image is not published on Instagram . Am I missing something? Can someone help me with this?

thanks

+6
source share
1 answer

First, in your code, you are not assigning the return value of setupControllerWithURL: usingDelegate: object, so this method does not actually do anything by simply creating a new instance of UIDocumentInteractionController and discarding it.

Secondly, from the documentation:

 "Note that the caller of this method needs to retain the returned object." 

You do not save the controller document (or assign it to a strictly specified property in the case of ARC) from what I can say.

Try this - In your @interface:

 @property (nonatomic, strong) UIDocumentInteractionController *documentController; 

In your @implementation:

 self.documentController = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile]; self.documentController.delegate = self; self.documentController.UTI = @"com.instagram.photo"; [self.documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; 

In addition, the string NSURL *igImageHookFile = [[NSURL alloc] init]; not needed, because in the next line igImageHookFile = [NSURL fileURLWithPath:jpgPath]; you create a new instance and discard the first. Just use NSURL *igImageHookFile = [NSURL fileURLWithPath:jpgPath];

0
source

All Articles