从iOS照片库删除图像

问题描述:

我创建了一个应用程序,该应用程序从手机的照片库中获取图像并将其显示在收藏夹视图中.现在,我希望每当用户选择一个图像并单击删除按钮时,该特定图像就会从集合视图以及图像库中删除.我正在使用ALAssetLibrary来获取图像.我进行了很多搜索,但没有找到从照片库中删除图片的任何方法.

I have created an Application that fetches Images from the photo library of the phone and displays it on a collection view. Now, I want that whenever the user selects an image and click on a delete button that particular image gets deleted from the collection view as well as from the image library. I am using ALAssetLibrary to fetch the images. I searched a lot but did not find any way to delete the image from the photo library.

有人可以告诉我如何从应用程序中以编程方式从照片库中删除照片.

Can anybody tell me that how I can delete a photo from photo library programmatically from my application.

您可以将库中的文件复制到应用程序的文件系统沙箱中,您可以在其中使用它们进行任何操作.但是,您的应用程序无法修改沙箱外部的文件.这包括图库中的文件.

You can copy files from the gallery into your application's file system sandbox, where you can do anything you want with them. However, your application can't modify files outside the sandbox. This includes files in the gallery.

此答案所说,似乎不是定义的在那里删除照片的方法.

As this answer says, there doesn't appear to be a method defined for deleting photos there.