HJCached 图像导致表视图滞后
我正在为寿司吧编写一个应用程序。菜单层次结构由表格视图(自定义单元格) ==> 表格视图(自定义单元格) ==>组成 视图
在第一个表格视图中,有食物类别的图片(取自该类别中的第一道菜的图片),在第二个表格视图中 - 菜肴的图片,在描述视图中 - 相同菜肴图像,但尺寸较大。
图片从链接异步下载(从json菜单解析)并由库HJCache缓存。一切正常,一切都已加载,但是..滚动桌面视图时存在一些滞后 - 我的意思是滚动不平滑。我以为是内存泄漏,但什么也没发现。
图片的原始尺寸 - 大约 450/300,在自定义表格单元格中,它必须适合 120/80。程序会因为图片太大而变得缓慢和卡顿吗?
I am writing an application for a sushi bar. The menu hierarchy consisting of a table view (custom cell) ==> table view (custom cell) ==> view
In the first Table View there is pictures of food categories (picture taken from the first dish in this category), in the second - pictures of dishes, in a description view - the same dish image, but in larger size.
Pictures are downloaded asynchronously from the links (which are parsed from json menu) and cached by the library HJCache. Everything works, everything is loaded, but .. When scrolling tableview there are some lags - I mean scrolling is not smooth. I thought that was memory leak, but found nothing.
The original size of pictures - something about 450/300, in a custom table cell, it must fit in 120/80. Can the program be slow and laggy because of too large size pictures?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我强烈建议您看看他们是否可以在服务器上调整这些图像的大小。如果要缩小尺寸以适合表格单元格,那么确实没有理由下载每尺寸 300-450 像素的图像。如果我必须猜测性能影响(而且只是猜测),那么滚动性能影响是由完成加载图像并尝试将其添加到 UIImageView 引起的通过调整它的大小(可能有填充方面或类似的设置?)。
对您问题的简短回答:是的,大图像很可能会影响性能。即使它们是异步下载的,也没有理由传输超出您需要的数据。
I would strongly urge you to see if they could get those images resized on the server. There is really no reason at all to download 300-450 px per dimension images if they are going to be sized down to fit in a table cell. If I had to make a guess as to the performance hit (and its only a guess), it would be that the scrolling performance hit is caused by finishing loading the image and trying to add it to the
UIImageView
by resizing it (probably have Aspect for Fill or something similar set?).The short answer to your question: yes, its very likely the large images are the performance hit. Even if they are downloaded async, there is no reason to transfer more data than you need to.