iOS中存储图片到相册中的两种方式

来源:互联网 发布:美国反对美国 知乎 编辑:程序博客网 时间:2024/04/26 06:53

方式一:

UIImageWriteToSavedPhotosAlbum(self.imageV.image,self, @selector(image:didFinishSavingWithError:contextInfo:),nil);


- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{

    

    if (error) {

        [SVProgressHUDshowErrorWithStatus:@"保存失败"];

    }else{

        

        [SVProgressHUDshowSuccessWithStatus:@"保存成功"];

    }

}

方式二:

NSError * error = nil;

    __blockNSString * assetID = nil;

    [[PHPhotoLibrarysharedPhotoLibrary] performChangesAndWait:^{

       assetID =  [PHAssetChangeRequestcreationRequestForAssetFromImage:self.imageV.image].placeholderForCreatedAsset.localIdentifier;

    } error:&error];


1 0
原创粉丝点击