Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Table View Refresh Cell

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/remove images or indicators?

like image 496
user1120008 Avatar asked May 12 '12 00:05

user1120008


2 Answers

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];
like image 134
Mike Z Avatar answered Oct 09 '22 09:10

Mike Z


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

UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[cell reloadInputViews];
like image 33
user1139921 Avatar answered Oct 09 '22 10:10

user1139921