登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> CLQ工作室开源代码 >> 主题: [ios] imageWithContentsOfFile 有坑尽量不要用?     [回主站]     [分站链接]
标题
[ios] imageWithContentsOfFile 有坑尽量不要用?
clq
浏览(286) + 2022-03-17 16:13:51 发表 编辑

关键字:

[2022-03-17 16:33:55 最后更新]
[ios] imageWithContentsOfFile 有坑尽量不要用

[UIImage imageNamed:fn] 会缓存图片我是知道的,没想到 imageWithContentsOfFile 其实也会缓存!
表现为: 使用 imageWithContentsOfFile 加载一张全路径图片后,这里再写入新的图片内容到同一全路径文件中,然后再用 imageWithContentsOfFile 加载,居然图片是不会更新的!

所以得换用以下的代码

NSData * image_data = [NSData dataWithContentsOfFile: image];
img = [UIImage imageWithData:image_data];
[ios_view setImage: img];

-----------------------------------------------------------
参考 https://www.cnblogs.com/crazypebble/p/5259641.html

似乎以上说法也不对,imageWithContentsOfFile 实测还是不会缓存的。但实测发现 imageNamed 有时候可以加载全路径文件?


总数:0 页次:1/0 首页 尾页  
总数:0 页次:1/0 首页 尾页  


所在合集/目录



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1