2014-03-12 179 views
0

我有以下幾行代碼:的iOS:UITableViewRowAnimationFade工作不正常

- (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]; 
     } 
    } 
} 

所以我請從當前UITableView數據所選擇的UITableViewCell在步驟1在步驟2中,animation應該發生。在步驟3中,所選數據將從datasource(plist)中刪除。步驟3的回調將重新加載我的UITableView

問題是,只有最後一個UITableViewCell刪除動畫。所有上面的UITableViewCells不。所以如果我有5個單元格,前4個單元格在刪除時沒有任何動畫。

我做錯了什麼?

回答

2
The callback of Step 3 will reload my tableView. 

您打電話給[tableView reloadData]嗎?在電話deleteRowsAtIndexPaths之後,在淡入淡出的動畫時間內,如果您撥打reloadData,淡入淡出的動畫將被覆蓋,則不能有任何淡入淡出的結果。因爲reloadData不會影響已刪除數據的最後一行,所以最後一行單元格具有淡出動畫。

+0

我會試試看。感謝您的關注。 – filou

+0

是的,這有助於:)。 – filou