PDA

View Full Version : Updating a Tableview's Cells after creation




jchildress
Sep 4, 2008, 04:57 PM
I have a tableview with custom cells that I would like to update whenever I need too. For example, each cell has an extra UILabel on the right side of the cell that contains a value of a setting. When you tap that cell, it loads up a new view where you can change the value of that setting. When the modified setting is save by pressing the save button on this new view, and the navigation controller takes you back to the original (top) view, I want the original tableView to update the cell with the newly modified value.

I think becuase the tableView code tries to save the cells to prevent them from being recreated, saving time and memory I assume, I think this is causing the cell to never update. Is there a method I can call to tell all cells or specific cells to update their Text\UILabels with the newly updated value?



Luke Redpath
Sep 4, 2008, 05:08 PM
You should be setting the contents for your cell each time tableView:cellForRowAtIndexPath: is called. If you update the source of your cell data then it should be updated automatically. What does your method look like?

PhoneyDeveloper
Sep 4, 2008, 06:50 PM
[UITableView reloadData] should cause everything to redraw. I assume you are setting the new value in your model object. The cells will be rebuilt with the new values.

Look at the CustomTableViewCell sample in the TableView Suite examples.