I have a simple UITableView with UITableViewCells. For the 0th row in the tableview, I have set a background color for the cell. Now on tapping the 0th row I just want the row to expand. In order to achieve this, I'm using the same technique as described here to change the 0th row height.
Now the problem is that the cell expands and collapses, but with each process there's an ugly flash/flicker on the cell. I've tried both beginupdates/endupdates and also reloading just that single row using [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
What's causing the flicker/flash on tapping? And how do I get rid of it? And yes, I forgot to mention, I have set the cell's selection style to none. So that's not causing this.
I had the same issue when using non-opaque background color of the cell. The solution is to use backgroundView
property, instead of backgroundColor
:
UIView *backgroundView = [[UIView alloc] initWithFrame:cell.frame];
backgroundView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.1f];
cell.backgroundView = backgroundView;
cell.backgroundColor = [UIColor clearColor];
I've had a similar issue, with a few culprits:
If you don't want animation and stop the cell from flashing, you can use following solution -
[UIView setAnimationsEnabled:NO];
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil]
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
[UIView setAnimationsEnabled:YES];
The above snippet will have no animation on cells while reloading the cell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With