将动画gif从AppData保存到相册 - iOS 11

时间:2017-08-15 05:33:13

标签: ios gif ios11

如何将Gif从Documents或AppData文件夹(或其他已知路径)保存到iOS 11相册?

已知路径的示例:/ var / mobile / Containers / Data / Application / [app uuid] /Documents/filename.gif

Older versions

question不断引用已弃用ALA*。你如何为iOS 11做到这一点?

1 个答案:

答案 0 :(得分:2)

添加框架基础和照片


#import <Foundation/Foundation.h>
#import <Photos/Photos.h>

int saveGifToGallery(const char *path0){

    NSString *path = [NSString stringWithUTF8String:path0];
    NSData *data = [NSData dataWithContentsOfFile:path];
    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
        PHAssetResourceCreationOptions *options = [[PHAssetResourceCreationOptions alloc] init];
        [[PHAssetCreationRequest creationRequestForAsset] addResourceWithType:PHAssetResourceTypePhoto data:data options:options];
    } completionHandler:^(BOOL success, NSError * _Nullable error) {
        NSLog(@":%d",success);
    }];

    return 1;

}