实现滑动出现删除按钮的代码
// Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. // if (indexPath.section == 0) { // return NO; // [self isViewLoaded]; // } return YES; } #pragma mark - 以下几行代码实现删除 // Override to support editing the table view. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // Delete the row from the data source [_favoriteArray removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; } - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleDelete; } #pragma mark - 让删除按钮显示为中文 - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{ return @"删除"; }
参考
http://stackoverflow.com/questions/1168593/how-to-delete-a-row-of-a-table-in-iphone
http://blog.csdn.net/a6472953/article/details/7530742 - 实现中文字"删除"
http://www.cppblog.com/Khan/archive/2011/10/14/158305.html - 点击"删除"实现删除相应行
https://github.com/yfujiki/YFJLeftSwipeDeleteTableView/blob/master/YFJLeftSwipeDeleteTableView/ViewController.m