本文介绍了如何将gif保存到相册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用UIImageWriteToSavedPhotosAlbum和ALAssetsLibrary将我的gif保存到相册中。但是,当我尝试通过电子邮件发送gif时,它没有动画效果。我很确定元数据在保存时会丢失。有谁知道如何保存gif元数据?
I've tried using UIImageWriteToSavedPhotosAlbum and ALAssetsLibrary to save my gif to the photo album. But when I try to email the gif it does not animate. I'm pretty sure the meta data is being lost when it gets saved. Does anyone know how I can preserve the gif meta data?
谢谢
推荐答案
相当古老的问题,但它可能对某人有所帮助!
Quite an old question, but it might help someone!
我使用此代码将GIF保存在相册中并且工作正常,通过在MailViewComposer中打开GIF进行测试和iMessage。
I use this code to save GIF in photo album and it works fine, tested by opening GIF in MailViewComposer and iMessage.
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSData *data = [NSData dataWithContentsOfFile:tempPath]; // Your GIF file path which you might have saved in NSDocumentDir or NSTempDir
[library writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@"Error Saving GIF to Photo Album: %@", error);
} else {
// TODO: success handling
NSLog(@"GIF Saved to %@", assetURL);
success(tempPath);
}
}];
这篇关于如何将gif保存到相册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!