iOS Table View Refresh Cell

前端 未结 3 1536
刺人心
刺人心 2021-02-04 01:46

I followed the advice in the link below to add images to cells in a table view.

Adding Image to Table Cell (iOS)

Is there a way to force refresh a cell i.e. add/

相关标签:
3条回答
  • 2021-02-04 02:22

    Since you already have indexPath of the cell, sometimes this may just do the job

    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    [cell reloadInputViews];
    
    0 讨论(0)
  • 2021-02-04 02:23

    You can call the reloadRows(at:with:) method of the UITableView class to reload certain rows of the UITableView instance using a given animation effect.

    Note that there are similarly named insertRows(at:with:) and deleteRows(at:with:) methods if instead you want to insert or delete certain rows in the UITableView instance.

    0 讨论(0)
  • 2021-02-04 02:31

    You can call [self.tableview reloadData]; on the tableview and refresh the entire table.

    Otherwise you can do this to refresh a single cell.

     [self.tableView beginUpdates];
     [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPathOfYourCell] withRowAnimation:UITableViewRowAnimationNone];
     [self.tableView endUpdates];
    
    0 讨论(0)
提交回复
热议问题