iPhone自定义UITableViewCell,滚动后显示图像 [英] iPhone Custom UITableViewCell with image after scroll

查看:47
本文介绍了iPhone自定义UITableViewCell,滚动后显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的具有自定义单元格的应用程序UItableView中,具有图像的单元格,但是在某些单元格中没有图像.首先,没有图像的地方是白色的.在该位置滚动表后出现其他图片.请帮助解决此问题.

解决方案

尽管您的答案正在提供一个可行的解决方案,但我认为这不是解决此问题的正确方法.

想象一下一个其中包含要使用表显示的1,000个NSString的NSArray.通过在一个具有该NSString唯一ID的单元格中显示它们,您基本上可以创建1,000个单元格!这会使您的应用变慢.整个想法是重复使用单元格,因此只创建比显示单元格多1-2个的单元格.

所以正确的解决方案是:处理它.

  1. 通过仅具有该类的唯一ID来重复使用单元格
  2. 自己重置/更新单元格的内容,假定内容不干净

ps在桌子上观看斯坦福iPhone课,第8位(约18:50),苹果公司的一位男士对此进行了解释.

http://www.stanford.edu/class/cs193p/cgi-bin/index.php

In my app UItableView with custom cells, cells with image, but in some cells has not image. In start the place without image is white. After scrolling table in that places appears others picture. Please help to fix this problem.

解决方案

although your answer is rendering a working solution, I think it is not the correct way to deal with this problem.

Imagine an NSArray with a 1,000 NSStrings in it that you want to display using a table. By showing them in a cell with a unique id for that NSString, you are basically creating a 1,000 cells! This would slow down your app. The whole idea is that cells are reused so that only 1-2 more than displayed are created.

So the correct solution: deal with it.

  1. reuse a cell by having a unique id just for that class
  2. reset/renew content of the cell yourself, assume dirty content

ps watch the Stanford iPhone class on tables, number 8 (around 18:50), a guy from Apple explains all this.

http://www.stanford.edu/class/cs193p/cgi-bin/index.php

这篇关于iPhone自定义UITableViewCell,滚动后显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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