Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableViewCellAccessory Disappears When Scrolled Off Screen
    primarykey
    data
    text
    <p>I have a UITableView filled with objects. In the <em>didSelectRowAtIndexPath</em> method i have a UITableViewCellAccessoryCheckmark appear when the row is selected and disappear when unselected.</p> <p>Heres the code for the <em>didSelectRowAtIndexPath</em> method:</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:NO]; UITableViewCell *curCell = [beerTable cellForRowAtIndexPath:indexPath]; if (curCell.accessoryType == UITableViewCellAccessoryCheckmark) { [curCell setAccessoryType:UITableViewCellAccessoryNone]; compareCount = (compareCount - 1); if (tableView == [[self searchDisplayController] searchResultsTableView]) { NSString *objBeer = [searchResults objectAtIndex:indexPath.row]; [compareBeers removeObject:[searchResults objectAtIndex:indexPath.row]]; [compareCarbs removeObject:[carbAmount objectAtIndex:[beerNames indexOfObject:objBeer]]]; } else { [compareBeers removeObject:[beerNames objectAtIndex:indexPath.row]]; [compareCarbs removeObject:[carbAmount objectAtIndex:indexPath.row]]; } } else { [curCell setAccessoryType:UITableViewCellAccessoryCheckmark]; compareCount = (compareCount + 1); if (tableView == [[self searchDisplayController] searchResultsTableView]) { NSString *objBeer = [searchResults objectAtIndex:indexPath.row]; [compareBeers addObject:[searchResults objectAtIndex:indexPath.row]]; [compareCarbs addObject:[carbAmount objectAtIndex:[beerNames indexOfObject:objBeer]]]; } else { [compareBeers addObject:[beerNames objectAtIndex:indexPath.row]]; [compareCarbs addObject:[carbAmount objectAtIndex:indexPath.row]]; } } if (compareCount &gt; 0) { if (compareOn == YES){ } else { compareButton.enabled = YES; UIImage *image = [UIImage imageNamed:@"redbutton.png"]; [compareButton setImage:image]; } } else { compareButton.enabled = NO; [compareButton setImage:nil]; [compareButton setCustomView:nil]; } } </code></pre> <p>I also have this as my <em>cellForIndexPath</em>:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CustomCell"; CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil]; for (id currentObject in topLevelObjects){ if ([currentObject isKindOfClass:[UITableViewCell class]]){ cell = (CustomCell *) currentObject; break; } } } // Setting separate tables correctly.... return cell; } </code></pre> <p>My problem is that when the cell that is selected is scrolled out of view the checkmark associated with that value is now gone when back into view.</p> <p>What should I do to keep the Checkmark from disappearing?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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