gpt4 book ai didi

ios - 避免 UIImage 的 imageNamed - 内存管理

转载 作者:可可西里 更新时间:2023-11-01 03:37:39 26 4
gpt4 key购买 nike

我正在浏览 this link ,我遇到了一个要点避免 UIImage 的 imageNamed。为什么我们应该避免这种情况?

最佳答案

它缓存图像而不释放它,直到它收到内存警告。我不确定,但我想如果您的应用程序有很多图片(大图片),它可能会导致应用程序崩溃

对我来说,我通常使用“imageWithContentsOfFile”:

[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileName ofType:nil]]

关于ios - 避免 UIImage 的 imageNamed - 内存管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7201029/

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