我想把图片地址分享到instagram上,我很清楚controller交互控制器是可以做到的。
但据我所知,instagram没有官方sdk来分享这张图片。所以我的问题是,在不使用uidocumentinteraction的情况下,是否可以使用sdk或PHPhotolibrary共享图像?
发布于 2016-03-28 22:53:00
最后我找到了一个解决方案。
UIImage *getImage=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgURL]]];
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest * assetReq = [PHAssetChangeRequest creationRequestForAssetFromImage:getImage];
NSString* localId = [[assetReq placeholderForCreatedAsset] localIdentifier];
NSString *escapedString = [localId stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@", escapedString]];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
} else {
NSLog(@"Instagram app not found.");
}
} completionHandler:^(BOOL success, NSError *error) {
if (!success){
NSLog(@"%@",error);
}
}];https://stackoverflow.com/questions/36054724
复制相似问题