是否可以从我的应用程序下载图像并将其存储在iPhone内存中?我的应用程序中提供了各种大小的图像(url)。如何从我的应用程序下载并将其存储在图库中?
答案 0 :(得分:2)
这会将图像保存到图库
UIImageWriteToSavedPhotosAlbum(yourImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void*)contextInfo
{
if (error != NULL)
{
// handle error
}
else
{
// handle ok status
}
}
更多信息 - 开发者文档页面 - https://developer.apple.com/library/ios/#documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html
如何下载和存储到图库:
UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"your_image_address.com"]]], self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
答案 1 :(得分:1)
尝试使用本教程。它显示了如何下载图像并存储到本地存储器http://sugartin.info/2012/01/10/permanently-download-image-and-fetch-locally-images/