user1780591
user1780591

Reputation: 207

Enable UITableView edit only in a specified section

I have a tableView with 4 sections. I want to enable editing (move/drag/ rearrange ) the cells only within the forth section. When I set: tableView.editing = YES I get all the table view to be in editing mode. This How to limit UITableView row reordering to a section helped me as I can now rearrange cells from a section only within their "root" section.

What I mean is if the cell is in the 1st section then I only get to rearrange within the 1st section and not the others. My goal is to enable editing only with The 4th section therefore putting in Move/drag Mode only the cells within the 4th Section. Does anyone know how I can do this?

Upvotes: 5

Views: 2001

Answers (1)

tkanzakic
tkanzakic

Reputation: 5499

You can achieve this by implementing this delegate method

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

Upvotes: 8

Related Questions