Display shift when adding rows to UITableView
Posted
by Kamchatka
on Stack Overflow
See other posts from Stack Overflow
or by Kamchatka
Published on 2010-06-14T01:05:31Z
Indexed on
2010/06/14
1:12 UTC
Read the original article
Hit count: 312
Hello,
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!
© Stack Overflow or respective owner