save image in camera roll and get asset url

后端 未结 1 584
野的像风
野的像风 2021-02-13 23:42

for an app I\'m developing, I use UIImagePickerController to shoot a picture and store it in camera roll:

- (void)imagePickerController:(UIImagePickerController*         


        
相关标签:
1条回答
  • 2021-02-14 00:36

    This solution should fix the problem:

        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library writeImageToSavedPhotosAlbum:((UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage]).CGImage
                                     metadata:[info objectForKey:UIImagePickerControllerMediaMetadata]
                              completionBlock:^(NSURL *assetURL, NSError *error) {
                                  NSLog(@"assetURL %@", assetURL);
                              }];
    

    et voila:

    assetURL assets-library://asset/asset.JPG?id=1611E84C-24E2-4177-B49A-1C57B4A9C665&ext=JPG
    
    0 讨论(0)
提交回复
热议问题