如何在iOS开发的UITableView中删除一个组中一行的数据?应该用什么方法?
您想如何删除它?是否要将单元格滑动到有删除按钮的位置,然后单击删除?或者什么的。。
//按钮显示内容
-(ns string *)table view:(UITableView *)table view titlefordeleteconfirmationbuttonforrowatdinexpath:(NSIndexPath *)index path {
Return @“删除”;
}
//下面是点击删除执行的方法。
-(void)table view:(UITableView *)table view commitEditingStyle:(UITableViewCellEditingStyle)editing style for rowatindexpath:(NSIndexPath *)indexPath {
}
1.如果你的数据是从服务器获取的,直接调用接口,再次获取数据源。
[table view reload data];就够了
2.如果您只想修改本地数据。
[_ data removeObjectAtIndex:[index path row]];//删除_data数组中的数据
[table view deleteRowsAtIndexPaths:[NSMutableArray array with object:index path]with row animation:uitableviewroanimationautomatic];//删除对应数据的单元格