Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Because <code>UITableView</code>'s typically reuse instances of the <code>UITableViewCell</code>'s, you must ensure your '<code>-tableView:cellForRowAtIndexPath:</code> method properly sets all attributes of the cell. Else stale data can persist. I'm guessing this may be your problem, lacking a complete look at your code.</p> <p>So, something like this:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* cellIdentifier = @"TheCellIdentifier"; UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; } ShoppingObject* shopping = [self.myShoppingList objectAtIndex:indexPath.row]; UIImageView* accessoryView = nil; if (shopping.isDone) { accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tick_btn"]]; } cell.accessoryView = accessoryView; return cell; } </code></pre> <p>It obtains the cell, either by from the reuse cache or by creating a new one. Then it checks the state of your data model to see if if shopping is done or not for the object being represented in that row, and if shopping is done gives you your image. Note that is shopping is not done, there is no accessoryView created, so whatever the state of the ShoppingObject is being represented at that table row, the accessoryView for that cell will be set correctly.</p> <p>So what I'd probably then do in your <code>-tableView:didSelectRowAtIndexPath:</code> would be to simply <code>-reloadData</code> on the table to ensure everything updates correctly.</p>
    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. 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