UITableViewCellAccessory Disappears When Scrolled Off Screen

前端 未结 5 519
独厮守ぢ
独厮守ぢ 2021-01-22 12:42

I have a UITableView filled with objects. In the didSelectRowAtIndexPath method i have a UITableViewCellAccessoryCheckmark appear when the row is selected and disappea

5条回答
  •  礼貌的吻别
    2021-01-22 13:34

    UITableViewCell are recycled when you scroll. So when you scroll the tableView down and up again, the cell you see may be different from the previously visible cell.

    You need to reset the status of a cell everytime in cellForRowAtIndexPath. You code has this comment area // Setting separate tables correctly....

    This is where you do the setting. When this is called, check if the cell is supposed to show a checkmark, and set it accordingly

提交回复
热议问题