滚动时读取 UIImage 数据,优缺点
我正在使用 NSFileManager
对我保存在设备上的一些图像进行某种滚动,
每次用户滚动到特定单元格时,我都会读取图像数据并加载它,并且滚动是有点慢而且不稳定,
目前要从磁盘读取图像,我使用 [NSFileManagercontentsAtPath: myFile]
然后使用 [UIImage imageWithData: imageData]
。
我想知道是否有更简单、更有效的方法来做到这一点, 我想过将图像预加载到内存中,但这些图像每个都是 700x700 像素,我担心这会导致内存使用过多,
无论如何,我还在其他一些线程上看到 JPG 表示似乎占用了更多内存比 PNG ,所以将所有内容更改为 PNG 后,它似乎工作得更好一些,但仍然不够快。
很想听听您的经历:)
Shai。
I'm doing some sort of scroller for some images i've saved on the device using NSFileManager
,
Everytime the user scrolls into the specific cell i read the image data and load it, and the scrolling is a bit slow and choppy,
Currently to read an image from the disk i use [NSFileManager contentsAtPath: myFile]
and then [UIImage imageWithData: imageData]
.
I wanted to know if theres an easier and more efficient way to do this ,
I thought of just preloading the images into memory, but these images are 700x700 pixels each and i'm afraid it would cause over-memory usage,
Anyways, i also saw on some other thread that JPG Representations seem to take up a lot more memory than PNG, so after changing everything to PNG , it seemed to be working a bit better, but still not fast enough.
Would love to hear from your experiences :)
Shai.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apple 有一个延迟图像加载示例,可以获取您开始从本地或网络位置加载图像。
Apple has a lazy image loading example that can get you started loading images from local or network locations.