Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法从 URL 加载图像并将其直接写入磁盘缓存(而不将它们呈现给UIImageView),以便我可以模拟急切加载?
UIImageView
问题源于需要呈现 100 多张图像,每张 4MB(不能将它们调整得更低);所以我们决定将它们全部下载到磁盘缓存中,向用户显示一个进度条,并在它们都在磁盘缓存中之后显示它们。
任何使用Hanake来模拟急切加载的解决方案都可以。
你可以下载并保存它,NSCache所以做类似的事情
NSCache
let cache = NSCache() cache.setObject(image, forKey: theURLYouDownloadedFrom)