Swipe-to-Delete feature shows a “Delete” button when a user swipes horizontally across a row.
To enable the swipe-to-delete feature of table views, you must implement the tableView:commitEditingStyle:forRowAtIndexPath: method.
Add the following code to enable the swipe-to-delete feature.
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//add code here to do what you want when you hit delete
[itemArray removeObjectAtIndex:[indexPath row]];
[tableView reloadData];
}
}