Display shift when adding rows to UITableView
I have a UITableView displaying an underlying NSFetchedResultsController.
When the fetchedResultsController is updated,
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {
is called. And the following is executed:
case NSFetchedResultsChangeInsert:
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:shiftedIndexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
The cellForRowAtIndexPath is only called for the new line (which is logical)
The problem is however that all the values displayed in the rows of the table view are shifted down. The first row displays its title. The second rows displays the first row's title. The third row the second row's title etc. If I repeat that, the third row will display the second's row title, the fourth the third row's title etc.
I don't understand what can happen, especially because cellForRowAtIndexPath is only called for the new line (which is logical) and not for all these lines. Additionally, if I click on these lines which have the wrong title, it opens the right document 开发者_开发技巧(didSelectRowAtIndexPath works correctly with the indexPath)
Any clue of what could happen? Thanks!
What is the code that is causing the delegate methods to get called? Please edit your answer and add in that code so that we can see the full lifecycle of this event.
Ill say, if your change needs to put an impact on all the rows available in TableView, than you definitely needs to call [tableView reloadData]
精彩评论