(1)- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingSt
(2)- (void)tableView:(UITableView *)tableView willBeginEditingRowAtInd
}
(3)- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexP
}
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil]withRowAnimation:UITableViewRowAnimationT
插入和删除差不多,在
- (void)tableView:(UITableView *)tableView commitEditingStyle:
(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
添加UITableViewCellEditingStyleInsert判断
- - (void)tableView:(UITableView *)tableView commitEditingStyle:
- (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
- NSUInteger row = [indexPath row];
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- [self.list removeObjectAtIndex:row];
- [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
- withRowAnimation:UITableViewRowAnimationAutomatic];
- }else if(editingStyle == UITableViewCellEditingStyleInsert ){
- NSArray *insertIndexPaths = [NSArray arrayWithObjects:indexPath,nil];
- [self.list insertObject:@"inset new Cell" atIndex:row];
- [tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationMiddle];
- }
- }
4.2 修改图标为插入样式。
- - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
- editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
- return UITableViewCellEditingStyleInsert;
- }