iOS图片保存到相册的方法

2019-07-27  本文已影响0人  杯中怎可无酒

plan 1 此种方法失败几率很高

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

plan 2 此种方法是同步操作,需要等待存储过程完成

NSError *error = nil;
  [[PHPhotoLibrary sharedPhotoLibrary] performChangesAndWait:^{
        [PHAssetChangeRequest creationRequestForAssetFromImage:cell.adImageView.image];
    } error:&error];

plan 3 此方法是异步操作,如果完成后需要别的操作可能会出现问题,需要额外注意

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
        
    } completionHandler:^(BOOL success, NSError * _Nullable error) {
        
    }]

上一篇 下一篇

猜你喜欢

热点阅读