我使用此代码从图像选择器选择的照片应用程序中删除图像。
选择多个图像后,它将在assetArray中返回所选图像。
现在,我想删除这些图像,但是会出现错误“对象必须为PHAsset类型”

 - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickingAssets:(NSArray *)assetArray
     {
      [picker.presentingViewController dismissViewControllerAnimated:YES completion:nil];
NSLog(@"===%@===",assetArray);
void (^completionHandler)(BOOL, NSError *) = ^(BOOL success, NSError *error) {
    if (success) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [[self navigationController] popViewControllerAnimated:YES];
        });
    } else {
        NSLog(@"Error: %@", error);
    }
};

   // Delete asset from library
      [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
      [PHAssetChangeRequest deleteAssets:@[assetArray]];
} completionHandler:completionHandler];

  NSLog(@"GMImagePicker: User ended picking assets. Number of selected items is: %lu", (unsigned long)assetArray.count);
}

最佳答案

你做了一个数组数组,就像这样:

[PHAssetChangeRequest deleteAssets:assetArray];

10-07 21:24