提高 iPhone UITableView 滚动性能的技巧? [英] Tricks for improving iPhone UITableView scrolling performance?

查看:27
本文介绍了提高 iPhone UITableView 滚动性能的技巧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 uitableview 可以在每个单元格中加载相当大的图像,并且单元格的高度取决于图像的大小.滚动性能不错,但有时会很不稳定.

I have a uitableview that loads fairly large images in each cell and the cell heights vary depending on the size of the image. Scrolling performance is decent, but can sometimes be jerky.

我在 FieryRobot 博客上找到了这些技巧:

I found these tips I found on the FieryRobot blog:

glassy-scrolling-with-uitableview

more-glassy-scrolling-with-uitableview

有没有人有任何提高 uitableview 滚动性能的技巧?

Does anyone have any tips for improving uitableview scrolling performance?

推荐答案

  1. 缓存行的高度(表视图可以频繁请求)
  2. 为表中使用的图像创建一个最近最少使用的缓存(并在收到内存警告时使所有非活动条目无效)
  3. UITableViewCelldrawRect: 中绘制所有内容,尽可能避免使用子视图(或者如果您需要标准的辅助功能,内容视图的 drawRect:)
  4. 使您的 UITableViewCell 图层不透明(如果您有内容视图,则同样如此)
  5. 使用 UITableView 示例/文档推荐的 reusableCellIdentifier 功能
  6. 避免未预烘焙到 UIImages
  7. 的渐变/复杂图形效果
  1. Cache the height of the rows (the table view can request this frequently)
  2. Create a least-recently-used cache for the images used in the table (and invalidate all the inactive entries when you receive a memory warning)
  3. Draw everything in the UITableViewCell's drawRect: if possible avoid subviews at all costs (or if you require the standard accessibility functionality, the content view's drawRect:)
  4. Make your UITableViewCell's layer opaque (same goes for the content view if you have one)
  5. Use the reusableCellIdentifier functionality as recommended by the UITableView examples/documentation
  6. Avoid gradients/complicated graphical effects that aren't pre-baked into UIImages

这篇关于提高 iPhone UITableView 滚动性能的技巧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆