2016-03-17 86 views

回答

1

最後我找到了解決方案。

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); 
    } 
}]; 
相關問題