How to properly toggle UITableViewCell's accesoryType on cell selection/deselection?

前端 未结 4 1740
野性不改
野性不改 2021-01-03 06:08

I\'m trying to toggle accesoryType when a table cell is selected/deselected... the behavior should be: tap -> set accessoryType to UITableViewCellAc

4条回答
  •  暖寄归人
    2021-01-03 06:39

    Tapping the cell again equates to selection of the cell and not deselection.

    You need to have a toggle in the - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath method to check if the cell.accessoryType == UITableViewCellAccessoryCheckmark.

提交回复
热议问题