Table view cell only masks correctly after scrolling off and then back on

后端 未结 6 1616
無奈伤痛
無奈伤痛 2021-02-04 06:08

I\'m modifying a table view cell during a call to tableView:cellForIndexPath, but the modifications do not appear until the cell is scrolled off and then back on. I

6条回答
  •  悲哀的现实
    2021-02-04 06:44

    I'm modifying a table view cell during a call to tableView:cellForIndexPath, but the modifications do not appear until the cell is scrolled off and then back on.

    This method won't be called until the cell needs to be recycled (i.e appears from off-screen). Cells already in the tableview don't have this method called since they are already visible. I'm wondering (since this code works fine) if you have confused the delegate callback? These methods only trigger when a new cell scrolls into view (and a cached cell needs to be reconfigured).

    if you call - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation; you would be able to trigger a redraw on a cell, or [tableview reloadData] to refresh all cells

提交回复
热议问题