views:

861

answers:

2

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.

+1  A: 

Your problem here is due to the way your are using the cell queue in the UITableView, I think you are not giving each one of your cells a unique cell identifier, because of this you are experiencing that pictures swap from one cell to another.

Daniel
Thank you, the table work fine now :)
Mark as answer then :)
Daniel
+2  A: 

hi Daniel,

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

Dirk de Kok
Problem is when the user has specified the content, gotta sotre it somehow
Daniel