数据展示就不写了,加上如下代码:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
    return YES; 
} 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
     if (editingStyle == UITableViewCellEditingStyleDelete) { 
         [dataArray removeObjectAtIndex:indexPath.row]; 
         // Delete the row from the data source. 
         [testTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
     }    
     else if (editingStyle == UITableViewCellEditingStyleInsert) { 
     // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. 
     }    
 }启用上面两个代理,并增加数据删除操作:
[dataArray removeObjectAtIndex:indexPath.row];
 在一条数据上向右划动一下.
[img]http://dl2.iteye.com/upload/attachment/0101/9471/c72c98c0-d4af-35ef-bede-1e54c687e551.png[/img]
点Delete.
[img]http://dl2.iteye.com/upload/attachment/0101/9473/ce9516f7-7a5a-3e7a-ac6b-8c4f6f50224d.png[/img]
是不是就成功删除了一条数据呢?
 按理说故事讲到这里也就讲完了.但是笔者想延伸一下.注意看图二划动以后的"Delete",你有没有想把这个东东改掉的冲动呢?比如改成:下载?其实很简单,其实下面这个代理方法:
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{ 
        return @"下载"; 
}再划动一下,是不是变了呢?
                









