删除相册最后一个照片

//    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

推荐阅读更多精彩内容

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