图片不在ios上发布instagram 6

问题描述:

我正在使用instagram-ios-sdk将Instagram集成到我的应用程序中。我可以成功地将login发送给Instagram并获取访问令牌,但之后当我尝试使用UIDocumentInteractionControllerUIImagePickerController发布图片时,图片不会发布。发送图片的代码如下给出:图片不在ios上发布instagram 6

(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; 
} 

我转换的图像,以.ig格式,具有的(612 * 612)的分辨率。但仍然没有张贴在Instagram上。我错过了什么吗?谁能帮我这个?

感谢

+0

同样的问题在这里。 :(如果你确实搞清楚了,请你可以跟我分享你所做的事情 –

+0

你们有没有想过吗? –

首先,在你的代码,你没有的setupControllerWithURL: usingDelegate:返回值分配给一个对象,这样的方法并不实际完成什么,只是创造UIDocumentInteractionController的一个新实例,将其丢弃。

其次,从文档:

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

你不保留文档控制器(或者在ARC的情况下,分配给强引用的属性)从我可以告诉。因为在下一行igImageHookFile = [NSURL fileURLWithPath:jpgPath];你创建一个

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

而且,线NSURL *igImageHookFile = [[NSURL alloc] init];是不必要的:

@property (nonatomic, strong) UIDocumentInteractionController *documentController; 

在你的@implementation: 在你@interface -

试试这个新实例并丢弃第一个实例。只需使用NSURL *igImageHookFile = [NSURL fileURLWithPath:jpgPath];

+0

我完成了这一切,但结果是相同的图像不张贴在这,是否有可能它只在设备中工作不在模拟器中。我能做什么??? – chakshu

+0

我试过[self.documentInteractionController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES]; 它的工作原理感谢daltonclaybrook .. :) – chakshu

+0

Can我知道这个图像被成功分享给instagram?我只想在图像共享成功时更新我的​​数据库。 – Manthan