I have a custom view in a custom table cell. Every time a specific property on the custom view is changed I call [self setNeedsDisplay] which redraws the view in - (void)drawRect:(CGRect)rect. That property is set in the table view delegate's tableView:cellForRowAtIndexPath:. But when the table view is larger than the screen and cells have to be reused, drawRect isn't called every time setNeedsDisplay is. Especially when I flick the table quickly . Slow scrolling works fine. This leads to the information in the first and last cells often being incorrect.
In the log I can see that normally, for every call to setNeedsDisplay there is a call to drawRect, but when I scroll the table view quickly there are more calls to setNeedsDisplay than drawRect. Surely there should be a one-to-one ratio here.
I use the same custom view in a normal UIView, and it redraws perfectly every time I call setNeedsDisplay. The problem seems isolated to table views and reusing cells.
Does anyone know what's going on here? Is there any other way to force the custom view to redraw itself?