Enable editing UITableView only in the specified section

I have a tableView with 4 sections. I want to enable editing (move / drag / rearrange) cells only in the fourth section. When I set:, tableView.editing = YESI get the whole view of the table in edit mode. This How to limit the reordering of a UITableView string in a section helped me, since now I can reorder cells from a section only in their "root" section.

I mean, if the cell is in the 1st section, then I can only rearrange to the 1st section, not the others. My goal is to allow editing with only the 4th section, so in Move / Drag mode, only move cells in the 4th section. Does anyone know how I can do this?

+5
source share
1 answer

You can achieve this by running this delegate method

-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 3) {
        return YES;
    } else {
        return NO;
    }
}
+6
source

All Articles