我的概念在UITableView中刪除行有一個小問題。用戶刪除一行後,我不想觸發:UITableView commitEditingStyle不刪除單元格
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
相反,我想更改編輯的單元格文本和背景,而不隱藏它。我的方法工作得很好:
if (editingStyle == UITableViewCellEditingStyleDelete) { NSMutableArray *previous_points = [self.trip_arrayOfAllPoints mutableCopy]; [previous_points removeObjectAtIndex:indexPath.row]; self.trip_arrayOfAllPoints = nil; self.trip_arrayOfAllPoints = [[NSMutableArray alloc] initWithCapacity:[previous_points count]]; self.trip_arrayOfAllPoints = [previous_points mutableCopy]; self.trip_arrayOfAllPointsEDITED = [[NSMutableArray alloc] initWithCapacity:[previous_points count]]; self.trip_arrayOfAllPointsEDITED = [previous_points mutableCopy]; //[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight]; self.trip_isArrayOfAllPointsEDITED = YES; }
但刪除行並不承擔dissapearing的動畫完成後,「刪除」標籤上當前單元格。是否有解決刪除行的「Apple方式」?
編輯 - 我已經工作了
這是非常簡單樸素。只需更換與deleteRowsAtIndexPaths:
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
在此之後「刪除」的動畫會消失,細胞仍然是在它的地方。
將此方法留空並查看按刪除時發生的情況。簡單地/ *在開頭和* /在結尾。 – solgar 2012-07-26 09:23:22
謝謝你,在我發佈信息之後,我決定將方法留空並用我的細胞進行操作。這解決了我的問題(這太簡單了:))。 – 2012-07-26 09:26:38