I have a UITableView with the following layout
TableView
-> CustomCell
--> CustomLabel
My custom label has some drawing code that if a property @property (nonatomic) bool animated; is YES, it will draw the contents animated, and if it is NO, will draw it’s contents without animation.
By default bool animated is NO.
So when the table view intially loads it’s data and redraws the cell, the content is draw without animation.
Now this is where I become unstuck.
The effect I’m after is that when a user clicks the cell, the data for the cell is updated and the content gets redrawn animated.
I trigger this like so,
[sender setTitle:newValue forState:UIControlStateNormal];
cell.noteTitle.animated = YES;
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:pathOfTheCell, nil] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
The problem is that while I am setting,
cell.noteTitle.animated = YES;
when I call
cell.noteTitle.animated = YES;
it seems to create a new instance of the CustomCell which as I’ve described above, has animated = NO.
So my question is this, how can I call my draw my custom cell, so that it doesn’t animate the when table loads the cell, but does animate when the user changes the cell value.
As I was rewriting this question, I stumbled upon the answer.
In
didSelectRowAtIndexPathI store the current selected path, then incellForRowAtIndexPathcheck if the current cell being drawn in the one that was selected, then set the animated property accordinglyThanks for the help guys, I realise I should have included more code in the original question