Which method should I use in order to display a cell again in a UITableViewController
?
views:
117answers:
2
+1
A:
If your data has been updated you can refresh the view by sending the reloadData message to your tableView:
[myTableView reloadData];
Apple's UITableView reference
Niels Castle
2009-11-08 11:35:26
A:
If you want to reload specific cells, use UITableView
's reloadRowsAtIndexPaths:withRowAnimation:
method. For example, if you want to reload the cell at row 20 in section 0 and the cell at row 4 in section 2 without an animation:
[cell reloadRowsAtIndexPaths:[NSArray arrayWithObjects:
[NSIndexPath indexPathForRow:20 inSection:0],
[NSIndexPath indexPathForRow:4 inSection:2],
nil]
withRowAnimation:UITableViewRowAnimationNone];
If you want to reload all the cells in the table view, then use UITableView
's reloadData
method (but be aware of the performance implications):
[tableView reloadData];
Alternatively, if you just want to redraw a cell (rather than reloading it in order to update its information), you can use UIView
's setNeedsDisplay
method:
[[cell view] setNeedsDisplay];
Steve Harrison
2010-05-01 01:38:04