Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, you are not calling <code>[super prepareForReuse]</code> like you should.</p> <p>And the documentation is pretty clear, you should be setting the image in <code>tableView:cellForRowAtIndexPath:</code> because it's content.<br> If you set the image in <code>tableView:cellForRowAtIndexPath:</code> there is no point to set it to nil in <code>prepareForReuse</code>.</p> <p>Imagine the following flow. </p> <ol> <li>You scroll down, cell 0 is put onto the queue. </li> <li><code>prepareForReuse</code> sets imageView.image to nil</li> <li><code>tableView:cellForRowAtIndexPath:</code> dequeues the cell and sets imageView.image to image1</li> </ol> <p>You are setting imageView.image twice. </p> <p>If you use nil there might be no measurable performance impact at all. But you might come to the idea to actually set a placeHolder image. So the cell is queued and prepared for reuse, you set the placeholder image; later the cell is dequeued and the placeholder image is replaced by a real image before the placeholder image was even visible.</p> <p>I would remove the <code>prepareForReuse</code> method completely. You don't need it if you set the image in <code>tableView:cellForRowAtIndexPath:</code></p> <hr> <p>from the <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006938-CH3-SW33" rel="nofollow">documentation</a>:</p> <blockquote> <p>If a UITableViewCell object is reusable—that is, it has a reuse identifier—this method is invoked just before the object is returned from the UITableView method dequeueReusableCellWithIdentifier:. <strong>For performance reasons, you should only reset attributes of the cell that are not related to content, for example, alpha, editing, and selection state. The table view's delegate in tableView:cellForRowAtIndexPath: should always reset all content when reusing a cell.</strong> If the cell object does not have an associated reuse identifier, this method is not called. If you override this method, you must be sure to invoke the superclass implementation.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload