iOS中儲存圖片到相簿中的兩種方式
阿新 • • 發佈:2019-02-07
方式一:
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
} error:&error];