gpt4 book ai didi

ios - iOS 最佳图片缓存策略

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:40:15 25 4
gpt4 key购买 nike

在我的应用程序中,我有一个 UITableView,它显示相当大的图像并加载一个适度设计的 Xib 文件来显示它。每个图像大约 700KB 到 1MB尺寸。流程几乎永无止境,随着我们向下滚动,它会加载越来越多。所以你可以想象我遇到了内存问题。

我尝试过使用 SDImageCacheNSCache。前者使用磁盘内存来缓存图像。在这两种情况下,缓存都不会自动清除图像。当我收到 Received memory warning 提示时,我不得不手动清除它们。每次我清除这些缓存时,释放的内存似乎每次都更少。

现在我很困惑我必须为这么长的图像列表使用哪种缓存策略。我可能在某处漏水了吗?当我分析应用程序时,它们肯定没有出现。

P.S.:我正在从网络加载图像。只是为了清楚。

最佳答案

来自文档:

UIImage 

+(UIImage *)imageNamed:(NSString *)name

Discussion This method looks in the system caches for an image object with the specified name and returns that object if it exists. If a matching image object is not already in the cache, this method loads the image data from the specified file, caches it, and then returns the resulting object.

所以我想将它留给 UIImage 类是一个好方法。

希望这对您有所帮助!

关于ios - iOS 最佳图片缓存策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19040265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com