Update UITableViewCell without reload

后端 未结 4 1218
广开言路
广开言路 2020-12-18 11:56

So here\'s my situation:

I have a UITableView where each cell has some buttons.
In the cellForRowAtIndexPath I set the indexpath of the row so when the a button

相关标签:
4条回答
  • 2020-12-18 12:42

    You should be able to redraw the tableview without a full reload by starting and ending an update like this:

    [tableView beginUpdates];
    [tableView endUpdates];
    
    0 讨论(0)
  • 2020-12-18 12:52

    call the method: - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

    0 讨论(0)
  • 2020-12-18 12:55

    Think you need to use this...

    - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
    

    Apple reference!

    0 讨论(0)
  • 2020-12-18 12:59

    It is better not to store the indexPath with the buttons. In the button action handler (which is either a method in your cell subclass or in your viewController) you could identify the cell, and subsequently determine the indexPath using -indexPathForCell:.

    0 讨论(0)
提交回复
热议问题