Quote:
Originally Posted by colionel
This is really simple, since OS 3.0 just set the background color of the cell in the willDisplayCell method.
You must not set the color in the cellForRowAtIndexPath.
This works for both the plain and grouped style :
Code:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor redColor];
}
P.S: Here the documentation extract for willDisplayCell :
"A table view sends this message to its delegate just before it uses cell to draw a row, thereby permitting the delegate to customize the cell object before it is displayed. This method gives the delegate a chance to override state-based properties set earlier by the table view, such as selection and background color. After the delegate returns, the table view sets only the alpha and frame properties, and then only when animating rows as they slide in or out."
|
This is fantastic! Thank you so much for posting this.