参考:
http://code4app.com/snippets/one/自定义UITableViewCell上的delete按钮/513ea0586803faee3c000000
//通过UITableViewDelegate方法可以实现删除 tableview中某一行
//滑动删除
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
[bookInforemoveObjectAtIndex:row];//bookInfo为当前table中显示的array
[tableView deleteRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationLeft];
}
/*此时删除按钮为Delete,如果想显示为“删除” 中文的话,则需要实现
UITableViewDelegate中的- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath方法*/
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
return @"删除";
}
//或者,最简单的方式,将plist中的Localization native development region改为China即可
//通过UITableViewDelegate方法可以实现删除 tableview中某一行
//滑动删除
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
[bookInforemoveObjectAtIndex:row];//bookInfo为当前table中显示的array
[tableView deleteRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationLeft];
}
/*此时删除按钮为Delete,如果想显示为“删除” 中文的话,则需要实现
UITableViewDelegate中的- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath方法*/
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
return @"删除";
}
//或者,最简单的方式,将plist中的Localization native development region改为China即可