从代码iOS中删除相机胶卷中的图像 [英] Delete images in camera roll from code iOS

查看:169
本文介绍了从代码iOS中删除相机胶卷中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在我的应用没有创建的照片应用中删除相机胶卷中的图像(和视频)。我知道您无法从资产库中删除您的应用未创建的内容。但这个应用程序不在应用程序商店。它位于自助服务终端类型的环境中。所以我可以使用私有API。

Is there a way to delete images (and videos) in camera roll in the photos app that my app didn't create. I know you can't delete things from Asset Library that your app didn't create. But this app isn't on app store. It's on a kiosk type environment. So I can use private APIs.

所以有没有办法使用苹果公司不会批准应用程序商店的私有API来实现这一点,但这对我的情况有用。

So is there a way to do this using private APIs that apple would not approve for the app store, but would work for my situation.

谢谢。

推荐答案

是的,你可以在iOS上做到这一点8使用Photos框架。

Yep, you can do this in iOS 8 using Photos framework.

例如,如果您有资产URL存储在NSArray * assetsURLs

For example if you have Assets URLs stored in NSArray *assetsURLs

PHPhotoLibrary *library = [PHPhotoLibrary sharedPhotoLibrary];
    [library performChanges:^{
        PHFetchResult *assetsToBeDeleted = [PHAsset fetchAssetsWithALAssetURLs:assetsURLs options:nil];
        [PHAssetChangeRequest deleteAssets:assetsToBeDeleted];
    } completionHandler:^(BOOL success, NSError *error)
     {
         //do something here
    }];

此代码将要求用户确认从相机胶卷中删除。

this code will ask user to confirm removal from Camera Roll.

这篇关于从代码iOS中删除相机胶卷中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆