I have a timer which calls the below code to reload a cell in the second section of my grouped UITableView. It works perfectly fine unless I scroll the screen up so that the first section/cell cannot be seen. Once it “springs back” to its correct position, I see that the text which should appear in section 0 has appeared in section 1 and vice-versa.
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:1]] withRowAnimation:UITableViewRowAnimationNone];
Does reloadRowsAtIndexPaths or cellForRowAtIndex path work from the top of the full (visible or invisible) cells, or does it only work starting on the cells that are visible on the screen? In other words, does section 0 actually change depending whether it is visible on-screen or not?
What else would cause cellForRowAtIndexPath to load the wrong data into the cells?
Ok, I played a bit with your project, here are my suggestions:
As you are adding the button to the cell, remember to remove it when you don’t want use it (when you refresh the cell, basically you create a new cell, and store the second one to reuse, so if you scroll down and then up, you’ll reuse that cell as the cell for the name).
for this to work, you must set the corresponding tag to the button:
And also, add the button directly to the cell, not to the contentView (this just worked for me, I’m not sure why).
EDIT: I uploaded a fixed version of your project, download it.