2

我无法使用 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];
    }
4

2 回答 2

2

Instagram 的最低分辨率为 612x612。始终为 JPG。

于 2012-12-23T15:17:12.053 回答
0

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

于 2014-11-07T10:32:59.283 回答