ALAssetsLibrary delete ALAssetsGroup / ALAsset

前端 未结 6 1530
终归单人心
终归单人心 2020-12-09 23:20

I have created \"photos album\" from my App, using IOS AssetsLibrary.

Reading ALAssetsLibrary,ALAssetsGroup and ALAsset documentations, i have seen methods to \"addA

6条回答
  •  鱼传尺愫
    2020-12-09 23:45

    evanchin is correct. Further more, if you want to do this in Xamarin.iOS (aka monotouch):

    var lib = new ALAssetsLibrary();
    lib.Enumerate(ALAssetsGroupType.All, (ALAssetsGroup group, ref bool libStop) =>
    {
        if (group == null)
        {
            return;
        }
        group.Enumerate((ALAsset asset, int index, ref bool groupStop) =>
        {
            if (asset != null && asset.Editable)
            {
                asset.SetImageDataAsync(new NSData(IntPtr.Zero), new NSDictionary(IntPtr.Zero));
            }
        });
    }, error => { });
    

    This code will delete all images that your app added to the ALAssetsLibrary.

提交回复
热议问题