我知道之间的区别UIImage(named:String)和UIImage(contentsOfFile:String),我只是有超过保存到200MB图像Images.xcassets文件夹.我发现我的应用程序有超大的内存使用量(超过500 MB),所以我考虑使用UIImage(contentsOfFile:String)构造函数,因为它不会缓存图像.我搜索了很多,并找到了以下解决方案.
myImageView.image = UIImage(contentsOfFile: NSBundle.mainBundle().pathForResource("my_img_name",ofType:"png"))
Run Code Online (Sandbox Code Playgroud)
Howerver,当它运行时,应用程序崩溃了.以下是可能与我的问题相关的链接:访问资产目录pathForResource
| 归档时间: |
|
| 查看次数: |
2775 次 |
| 最近记录: |