views:

929

answers:

4

I'm looking to do something simple such as drilling down on a particular UITableViewCell, which brings up a detail view controller. Within there, the user has the capability to change the attribute for the model underneath the cell. For instance, If I'm displaying a list of quotes, and a user clicks on a quote and favorites it in the child controller, I want to be able to display an image which was hidden now that it's favorited placed, a star perhaps. What's the easiest way to update one particular UITableViewCell in such as fashion? Is it best to reference the selected UITableViewCell into the child controller and couple them in such a fashion? How is something like this done?

Thanks.

A: 

To redraw a specific cell you should find its rectangle (rectForRowAtIndexPath) then call setNeedsDisplayInRect on the UITableView with this rectangle.

Andrew Grant
It sounds like he's trying to change the subviews of the table cell, not just force a redraw. It's rare that 100% custom drawing actually *works* for a table cell anyway...
Brent Royal-Gordon
+3  A: 

It's probably easier to simply update your model object and then call [tableView reloadData];.

Then change your drawing code to account for the changes and display your hidden images or whatever.

jpm
+1  A: 

For a complete code example have a look at the SQLite Books project on ADC.

slf
A: 

setNeedsLayout did it for me.

apalopohapa