对象必须是 PHAsset 类型
Objects must be of type PHAsset
我使用此代码从图像选择器选择的照片应用程序中删除图像。
选择多个图像后,它将 return assetArray 中的所选图像。
现在我想删除那些图片,但是它会报错"Object must be of type 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);
}
你做了一个数组 array.Just 这样做:
[PHAssetChangeRequest deleteAssets:assetArray];
我使用此代码从图像选择器选择的照片应用程序中删除图像。 选择多个图像后,它将 return assetArray 中的所选图像。 现在我想删除那些图片,但是它会报错"Object must be of type 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);
}
你做了一个数组 array.Just 这样做:
[PHAssetChangeRequest deleteAssets:assetArray];