I have a table view linked to a NSFetchedResultController
(i.e. loading data and also tracking changes to data is bound to the FRC)
I'm not using AutoLayout
in my cells (due to huge performance drop it introduces in iOS 8). I'm laying out my cells' content manually in cells (using -(void)layoutSubviews
). plus, the height of rows are calculated based on content and are cached/invalidated properly.
If any condition related to my data changes, related cells get updated individually (with the whole -(void)controllerWillChangeContent:...
through -(void)controllerDidChangeContent:...
delegate methods implemented) the animation for row updates is: UITableViewRowAnimationNone
The problem here is that, My cells have transparent backgrounds, and I can see some visual noise (most likely the actual cell getting stretched vertically, I can't say for sure because they are really transient and short lived) during [self.tableView reloadRowsAtIndexPaths:...];
.
I have tried many things to no avail!
Here are the things I have tried that doesn't work:
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
, returning the accurate value for estimated heights.self.tableView.rowHeight=UITableViewAutomaticDimension;
, helps a lot but doesn't fix it.[self.tableView beginUpdates];
and enabling after [self.tableView endUpdates];
-(void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
Things that help a little:
UIKit
counterparts doesn't solve the problem.-(void)layoutSubviews
in my cells shows that the cells with update condition get reloaded 3 times in a row upon each update in contrast with other cells getting updated just the once. I'm not forcing any [cell layoutIfNeeded];
or [cell setNeedsLayout];
anywhere.[self.tableView reloadData];
is not an option for me.At the end, I'm sorry I can't share any actual code, because it's not a test project and the complexity of the implementations renders any code sharing futile unless comprehended as a whole.
Thanks for your time.
I was also facing same problem of flickering UITableViewCell while using reloadRowsAtIndexPath, so what I did was -
[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.
Yeah, you can achieve a similar result from the @Sandy's answer using performWithoutAnimation
(Swift Version)
UIView.performWithoutAnimation {
self.tableView.reloadRows(at: [indexPath], with: .none)
}
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