My UITableView
is scrolling up once I add a new comment to CoreData. NSFetchedResultsController knows about it, puts this comment at the bottom of the table, an
I found something that worked for me. I encountered the same problem, and my estimatedRowHeight was 33 and all of my cells are greater than 33.
I just changed my estimatedRowHeight to my maximum cell height(or greater than your maximum cell height)
self.table.estimatedRowHeight = 310
self.table.rowHeight = UITableViewAutomaticDimension
worked like a charm, all cells are now autoresizing and uitableview is not scrolling to top or bottom when core data performs an update/delete/insert
Edited answer:
I was able to reproduce this glitch with the following steps:
UITableView
with its rowHeight
set to UITableViewAutomaticDimension
and non-zero estimatedRowHeight
.The source of this behavior needs additional investigation.
For now the only solution is not to use UITableViewAutomaticDimension
and return row heights from tableView:heightForRowAtIndexPath:
.
By the way, implementation of inverted index paths has one significant flaw. When FRC calls it's delegate method controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:
, all deletion index paths belongs to pre-change data set, and all insertion index paths - to post-change one. When you are in-beetween controllerWillChangeContent:
and controllerDidChangeContent:
, fetchedResultsController.fetchedObjects
will contain post-change data set, i suppose (needs to be checked, though).