删除某行 cell

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容