mardi 5 mai 2015

Changing an item in a custom UITableviewCell that is not visible

Suppose I have 10 items in my UITableView but only 4 items are being displayed at a time which changes when the user scrolls up or down. Now suppose I am on the 10th row so only the rows from 6->10 are being displayed. What should I do if I would like to change something on on the 2nd row.

Currently I have only 4 items and I am using the following approach

NSArray *cells = [tableView visibleCells];
for (CustomTableViewCell *cell in cells)
{
    if(cell.someproperty == 23)
    {
       //Show a certain image on the cell
       [cell.someButton setImage:[UIImage imageNamed:@"done.png"] forState:UIControlStateNormal];
    }
}

I realize the above approach probably wont work for items that are not being displayed (as those cells dont exist) because of dequeueReusableCellWithIdentifier being used. What options do I have any suggestions ?

Aucun commentaire:

Enregistrer un commentaire