Domanda

I have the following lines of code:

- (void)tableView:(UITableView *)tableView 
        commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
        forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [tableViewData removeObjectAtIndex:indexPath.row]; // Step 1
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
                         withRowAnimation:UITableViewRowAnimationFade]; // Step 2

        if (!queue_C5K) { // Step 3
            LockrNotificationDataKeeper *LLDK = 
             [[LockrNotificationDataKeeper alloc] initWithData:@"##deletion##" 
                                                  andIndexPath:(int)indexPath.row 
                                                       andType:@"dR" 
                                                      delegate:self];
            [queue_C5K addOperation:LLDK];
        }
    }
}

So I remove the selected UITableViewCell from the current UITableView data in Step 1. In Step 2, the animation should take place. In Step 3, the selected data is going to be removed from the datasource (plist). The callback of Step 3 will reload my UITableView.

The problem is, that only the last UITableViewCell removes with an animation. All upper UITableViewCells don't. So if I have 5 cells, the first 4 cells do not have any animation while deleting them.

What I am doing wrong?

È stato utile?

Soluzione

The callback of Step 3 will reload my tableView. 

Do you call [tableView reloadData] ? After call deleteRowsAtIndexPaths, during the fade animation time, if you call reloadData, fade animation will be covered then you can't any fade result. Because reloadData will not effect the last line which data already been removed, so the last line cell has the fade animation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top