Current location - Health Preservation Learning Network - Healthy weight loss - How to delete a row of data in a group in UITableView developed by iOS? What method should be used?
How to delete a row of data in a group in UITableView developed by iOS? What method should be used?
How do you want to delete it? Do you want to slide the cell to the position where there is a delete button, and then click Delete? Or something. .

//button to display content

-(ns string *)table view:(UITableView *)table view titlefordeleteconfirmationbuttonforrowatdinexpath:(NSIndexPath *)index path {

Return @ "Delete";

}

//Here's how to click Delete.

-(void)table view:(UITableView *)table view commitEditingStyle:(UITableViewCellEditingStyle)editing style for rowatindexpath:(NSIndexPath *)indexPath {

}

1. If your data is obtained from the server, call the interface directly and get the data source again.

[table view reload data]; That's enough

2. If you only want to modify local data.

[_ data removeObjectAtIndex:[index path row]]; //Delete the data in the _data array

[table view deleteRowsAtIndexPaths:[NSMutableArray array with object:index path]with row animation:uitableviewroanimationautomatic]; //Delete the cell of corresponding data.