Question

In my iPad app I'm using Apple's standard split view template. The master view has a table that's populated by a plist file and my table is split into three grouped sections. In my viewDidLoad method I've added the editbuttonitem that works as expected - tap it and you can then delete rows.

    self.navigationItem.rightBarButtonItem = self.editButtonItem;

However, I'd like the editbuttonitem, when selected, to only allow editing in the last two sections and not the first. Is this possible? And if so, can someone help point me the way?

Or will I need to not use Apple's built-in mechanism for this and have to code a unique barbuttonitem that can perform this task?

Much appreciated.

Was it helpful?

Solution

Try implementing the editingStyleForRowAtIndexPath method:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView 
       editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
        return UITableViewCellEditingStyleNone;
    else
        return UITableViewCellEditingStyleDelete;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top