简体   繁体   English

如何通过应用程序从设备的图片库中删除照片?

[英]How to delete photo from the Photo's Library of device through the application?

I am getting the images from the photos library through ALAssetsLibrary . 我正在通过ALAssetsLibrary从照片库获取图像。

I want to delete particular image from the photos library by performing select and delete operation from my application it self. 我想通过自己的应用程序执行选择和删除操作来从照片库中删除特定图像。 (Not from photos library) (不是来自照片库)

Using following code I am getting the images from the photos library : 使用以下代码,我从照片库获取图像:

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
    if(result != nil)
    {
        if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto])
        {
            ...
        }
    }
}

You can delete it with use of Photos Framework : 您可以使用Photos Framework将其删除:

+ (void)deleteAssets:(id<NSFastEnumeration>)assets

Documentation: here 文档: 此处

Example app: here 示例应用程序: 此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM