Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 图像未在ios 6的instagram上发布_Iphone_Ios_Instagram - Fatal编程技术网

Iphone 图像未在ios 6的instagram上发布

Iphone 图像未在ios 6的instagram上发布,iphone,ios,instagram,Iphone,Ios,Instagram,我正在使用Instagram ios sdk将Instagram集成到我的应用程序中。我可以成功地登录到Instagram并获得访问令牌,但之后,当我尝试使用UIDocumentInteractionController从UIImagePickerController发布图片时,图像不会被发布。发送图片的代码如下所示: (void)_startUpload:(UIImage *) image { NSLog(@"Image Object = %@",NSStringFromCGSize(

我正在使用
Instagram ios sdk将Instagram集成到我的应用程序中。我可以成功地
登录到Instagram并获得访问令牌,但之后,当我尝试使用
UIDocumentInteractionController
UIImagePickerController
发布图片时,图像不会被发布。发送图片的代码如下所示:

(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;
}
(无效)\u启动加载:(UIImage*)图像{
NSLog(@“Image Object=%@”,NSStringFromCGSize(Image.size));
NSString*jpgPath=[NSHomeDirectory()stringByAppendingPathComponent:@“Documents/Test.igo”];
[UIImageJPEGRepresentation(图像,1.0)WriteFile:jpgPath原子化:是];
NSLog(@“文件url%@”,jpgPath);
NSURL*igImageHookFile=[[NSURL alloc]init];
igImageHookFile=[NSURL fileURLWithPath:jpgPath];
NSLog(@“文件Url=%@”,IGIMAGEHOOK文件);
documentInteractionController.UTI=@“com.instagram.photo”;
[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[self-setupControllerWithURL:igImageHookFile usingDelegate:self];
[documentInteractionController PresentOpenMinumeFromRect:CGRectZero查看:self.view动画:是];
}
(UIDocumentInteractionController*)setupControllerWithURL:(NSURL*)fileURL usingDelegate:(id)interactionDelegate{
NSLog(@“%@”,fileURL);
UIDocumentInteractionController*interactionController=
[UIDocumentInteractionController interactionControllerWithURL:fileURL];
interactionController.delegate=interactionDelegate;
返回交互控制器;
}
我将图像转换为
.ig
格式,分辨率为(612*612)。但该图像仍然没有发布在Instagram上。我错过什么了吗?有人能帮我吗


谢谢

首先,在您的代码中,您没有将带有URL:usingDelegate:
setupcontroller的返回值赋给对象,因此该方法实际上没有完成任何事情,只是创建了UIDocumentInteractionController的一个新实例并将其丢弃

第二,从文件来看:

"Note that the caller of this method needs to retain the returned object."
self.documentController = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
self.documentController.delegate = self;
self.documentController.UTI = @"com.instagram.photo";
[self.documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
据我所知,您没有保留文档控制器(或者在ARC的情况下将其分配给强引用属性)

试试这个- 在@界面中:

@property (nonatomic, strong) UIDocumentInteractionController *documentController;
在@implementation中:

"Note that the caller of this method needs to retain the returned object."
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]是不必要的,因为在下一行
igImageHookFile=[NSURL fileURLWithPath:jpgPath]您正在创建一个新实例并丢弃第一个实例。只需使用
NSURL*igImageHookFile=[NSURL fileURLWithPath:jpgPath]

这里也有同样的问题:(如果你知道了,请告诉我你做了什么。你们中有人知道了吗?我做了所有这些,但结果是一样的图像没有发布在这,它是否可能只在设备中工作,而不是在模拟器中。我能做些什么???我试过了[self.documentInteractionController presentoptions menufromrect:self.view.frame-inView:self.view-animated:YES];它成功了,谢谢daltonclaybrook.:)我能知道图像已成功共享到instagram吗?我只想在图像成功共享时更新数据库。