Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In .h file create variable </p> <pre><code>UItableviewCell *selectedCell; </code></pre> <p>In didSelectRow method remove selection from saved cell and save new cell as selected:</p> <pre><code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath if (selectedCell) { selectedCell.accessoryType = UITableViewCellAccessoryNone; } UItableviewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if(cell.accessoryType == UITableViewCellAccessoryCheckmark) { cell.accessoryType = UITableViewCellAccessoryNone; else { cell.accessoryType = UITableViewCellAccessoryCheckmark; } selectedCell = cell; } </code></pre> <p>To prevent problems with reusable cells u can create NSIndexPath variable instead of UITableViewCell in .h file:</p> <pre><code>NSIndexPath *selectedCellIndexPath; </code></pre> <p>and change didSelectRow method:</p> <pre><code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath [tableView scrollToRowAtIndexPath:selectedCellIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO]; UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:selectedCellIndexPath]; selectedCell.accessoryType = UITableViewCellAccessoryNone; UItableviewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if(cell.accessoryType == UITableViewCellAccessoryCheckmark) { cell.accessoryType = UITableViewCellAccessoryNone; else { cell.accessoryType = UITableViewCellAccessoryCheckmark; } selectedCellIndexPath = indexPath; } </code></pre>
    singulars
    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.
    3. VO
      singulars
      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