gpt4 book ai didi

ios - iOS 中的图像缓存

转载 作者:行者123 更新时间:2023-11-28 23:15:06 24 4
gpt4 key购买 nike

如果我这样做

rowBackground = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bottomCell2.png"] 

图像在应用的整个生命周期内缓存,还是在我每次执行该指令时(在其他 View 或应用的一部分中)重新加载和重新缓存?

我在我的应用程序的每个表格 View 中都这样做。有效率吗?

提前致谢!

最佳答案

作为+imageNamed:的引用:

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.

缓存很高效,但是很吃内存。如果您的 TableView 包含大量图像,内存可能会耗尽。所以你可以考虑使用+imageWithContentsOfFile:或者其他类似的方法来加载图片。

关于ios - iOS 中的图像缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6792000/

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