Coocoo4Cocoa
Coocoo4Cocoa

Reputation: 50816

Question regarding updating a UITableViewCell on the iPhone

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.

Upvotes: 3

Views: 1739

Answers (4)

apalopohapa
apalopohapa

Reputation: 5183

setNeedsLayout did it for me.

Upvotes: 2

slf
slf

Reputation: 22767

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

Upvotes: 1

jpm
jpm

Reputation: 16702

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.

Upvotes: 5

Andrew Grant
Andrew Grant

Reputation: 58786

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

Upvotes: -1

Related Questions