I'm working in Objective C. I have a UITableViewController with about 25 cells that push to a UIViewController. When the user hits back, I want to see if the user entered the correct data for the given cell. (I have a working bool , we'll call it isCellComplete
for now). If isCellComplete is true, I want to add a checkmark as the accessory to the cell. I've been trying to put the test in cellForRowAtIndexPath
but that method does not seem to run and refresh the cells everytime the view appears. Anyone have suggestions?
You should look into the UITableView
method reloadRowsAtIndexPaths:withRowAnimation:
. This is much more elegant than reloading the whole table view. And if you don't want an animation, you can specify UITableViewRowAnimationNone
and it will look just like reloadData
but be much more efficient.
You should do the check in tableView:cellForRowAtIndexPath:
and if the check passes, set the cell's accessory to UITableViewCellAccessoryCheckmark
. Then when you tell the table view to reload the appropriate row(s), it'll automatically call tableView:cellForRowAtIndexPath:
on the data source and update that cell.