【问题标题】:Store it in phone memory - is it possible? ios?将其存储在手机内存中 - 可能吗? IOS?
【发布时间】:2012-02-09 06:23:15
【问题描述】:

是否可以从我的应用程序下载图像并将其存储在 iPhone 内存中?我的应用程序中有各种大小的图像(url)。如何从我的应用下载并将其存储在图库中?

【问题讨论】:

    标签: iphone objective-c ios xcode ipad


    【解决方案1】:

    这会将图像保存到图库

       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);
    

    【讨论】:

    • 嗨...非常感谢 Danielbeard。
    【解决方案2】:

    试试这个教程。它显示了如何下载图像并存储到本地内存http://sugartin.info/2012/01/10/permanently-download-image-and-fetch-locally-images/

    【讨论】:

    • 嗨.. 谢谢.. 但我不想将它存储在应用程序内存中。我想将图像存储在 iphone 常用功能的“照片”中。可以这样做吗?
    猜你喜欢
    • 1970-01-01
    • 2017-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-10
    相关资源
    最近更新 更多