删除相册最后一个照片

//    PHFetchResult *collectonResuts = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary options:[PHFetchOptions new]] ;

//    [collectonResuts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {

//        PHAssetCollection *assetCollection = obj;

//        NSLog(@"locname ==%@",assetCollection.localizedTitle);

//

//        if ([assetCollection.localizedTitle isEqualToString:@"所有照片"] || [assetCollection.localizedTitle isEqualToString:@"All Photos"])  {

//            PHFetchResult *assetResult = [PHAsset fetchAssetsInAssetCollection:assetCollection options:[PHFetchOptions new]];

//            [assetResult enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {

//                NSLog(@"assetResult.count === %lu",(unsigned long)(assetResult.count-1));

//                NSLog(@"idx === %lu",(unsigned long)idx);

//                [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{

//                    //获取相册的最后一张照片

//                    if (idx == assetResult.count-1) {

//                        [PHAssetChangeRequest deleteAssets:@[obj]];

//                        NSLog(@"删除成功");

//                    }

//                    NSLog(@"assetResult.count === %lu",(unsigned long)(assetResult.count-1));

//                } completionHandler:^(BOOL success, NSError *error) {

////                    NSLog(@"success: %d", success);

////                    NSLog(@"Error: %@", error);

//                }];

//            }];

//        }

//    }];




参考网址:https://www.jianshu.com/p/ac18aa3f28c2

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 相册适配 前言 由于在iOS8及以后苹果将原有的操作相册的ALAssetsLibrary framework替换为...
    wentianen阅读 1,959评论 0赞 6
  • 点语法的死循环注意 在set方法和get方法别用点语法,否则会产生死循环。以下两个方法会产生死循环 - (void...
    Wang99阅读 1,184评论 0赞 0
  • 转自:https://www.jianshu.com/p/10b2323f502e 1、禁止手机睡眠 [UIApp...
    aggie1024阅读 2,998评论 0赞 6
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 3,464评论 0赞 3
  • 1.查询相册使用权限PHAuthorizationStatus st = [PHPhotoLibrary auth...
    琦均煞Sylar阅读 888评论 0赞 0

友情链接更多精彩内容