删除某行 cell

作者: 失忆的程序员 | 来源:发表于2016-06-18 10:40 被阅读67次

didSelectRowAtIndexPath

你是要怎么个删除法。是要实现滑动cell出现删除按钮,然后点击删除? 还是什么。。

//按钮显示的内容

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {

   return @"删除";

}

//这里就是点击删除执行的方法

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

}

1.如果你的数据是从服务器获取的,那就直接调用接口,重新获取数据源 再

[tableView reloadData]; 就行

2.如果只想修改本地数据

[_data removeObjectAtIndex:[indexPath row]];  //删除_data数组里的数据

[tableview deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];  //删除对应数据的cell

相关文章

网友评论

    本文标题:删除某行 cell

    本文链接:https://www.haomeiwen.com/subject/ivovdttx.html