iOS engineer who likes clean, simple designs and sans-serif.

Loading

Deleting UITableView Rows

To enable edits of rows in a UITableView, use the canEditRowAtIndexPath and commitEditingStyle methods.
– canEditRowAtIndexPath allows you to set if each individual row is editable or not.
– commitEditingStyle only executes on delete. Make sure to reload the tableview or else the app will crash. Or you can use deleteRowsAtIndexPaths.

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Insert Code Here
}

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}

Leave a Comment