Я делаю приложение живого фото/обои. Я загружаю изображение и файл .mov с сервера. Теперь я застрял в сохранении этих файлов в каталоге документов. Как сохранить живые обои в каталоге документов. У кого-нибудь есть идея об этом, скажите мне. Вот мой кодКак сохранить живые/анимированные обои
SDWebImageDownloader *downloader = [SDWebImageDownloader sharedDownloader];
[downloader downloadImageWithURL:[NSURL URLWithString:imgFile]
options:0
progress:nil completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
if (image && finished) {
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [searchPaths objectAtIndex:0];
NSString* photoPath = [documentPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.JPG",strImg]];
[data writeToFile:photoPath atomically:YES];
}
}];
NSURL *URL = [NSURL URLWithString:str];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * downloadProgress){
NSLog(@"%f",downloadProgress.fractionCompleted);
NSString * str = [NSString stringWithFormat:@"%.2f",downloadProgress.fractionCompleted];
NSDictionary * infoDict = @{@"Download": str,
@"id":uniqId};
[[NSNotificationCenter defaultCenter]
postNotificationName:@"DownloadNotification"
object:self userInfo:infoDict];
}destination:^ NSURL *(NSURL *targetPath, NSURLResponse *response) {
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [searchPaths objectAtIndex:0];
NSString* videoPath = [documentPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.MOV",strImg]];
NSURL *videoUrl =[NSURL URLWithString:videoPath];
NSLog(@"%@",[videoUrl URLByAppendingPathComponent:videoPath]);
return videoUrl;
} completionHandler:^(NSURLResponse* response, NSURL *filePath, NSError *error) {
if(error)
{
NSLog(@"File Not Dowloaded %@",error);
[self downloadFile];
}
else {
NSLog(@"%@",filePath);
[self.downloadRecord removeObjectAtIndex:0];
if (self.downloadRecord.count > 0) {
[self downloadFile];
}
}
}];
Я знаю, что ... Я попытался сохранить пару живых обоев с помощью изображения (.jpg) с видео (.MOV) вместе (загружено и сохранено в каталоге документа), изображение сохранено успешно, но видео не удалось сохранить. Это главное. – salmancs43
То, как вы это сформулировали, звучит так, будто вы застряли, имея возможность ** всего ** сохранить его в каталоге документов. Я уточню свой ответ. – Greg
Да, если у вас есть решение, пожалуйста, скажите мне. – salmancs43