无法在iOS应用中集成Instagram

时间:2012-09-11 17:35:22

标签: instagram

我无法使用ios App在Instagram上发布我的照片。我从stackoverflow上的帖子中获得了以下代码,但它不起作用。 Instagram启动时,显示错误无法打开文件。请帮助我。

NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {

        NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
        NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"Image.ig"];
        NSData *imageData = UIImagePNGRepresentation([UIImage imageNamed:@"Icon.png"]);
        [imageData writeToFile:savedImagePath atomically:YES];
        NSURL *imageUrl = [NSURL fileURLWithPath:savedImagePath];
        docController = [[UIDocumentInteractionController alloc] init];
        docController.delegate = self;
        [docController retain];
        docController.UTI = @"com.instagram.photo";
        [docController setURL:imageUrl];
        [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
    }else{

        UIAlertView *errorToShare = [[UIAlertView alloc] initWithTitle:@"Instagram unavailable " message:@"You need to install Instagram in your device in order to share this image" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [errorToShare show];
        [errorToShare release];
    }

2 个答案:

答案 0 :(得分:2)

Instagram的最低分辨率为612x612。永远是JPG。

答案 1 :(得分:0)

为了完成,最低分辨率保持在 612x612 (这是由于在视网膜设备上显示图像),但Instagram现在支持 JPEG PNG 图片。发送到Instagram的所有非方形图像必须在发布之前裁剪。