Reputation: 11231
I have a UITableView With Two Sections. First section has one row and the section one has variable number of rows which varies according to data entry in database.
I want that user cant delete the cell from first section but he is able to delete the cells from the second section.
I have implemented the commitEditingStyle method for the tableview but the problem is it allows the user to delete the row from first section.
I can put some flag to check it in commitEditingStyle but what I want to do is just block it to show the editing button. That is user wont be able to see the delete button when he swips his or her finger on the table cell.
I did set the property editing=false but cant set editingStyle since it is readonly property. Setting editing=false doesnt work. tnx.
Upvotes: 0
Views: 288
Reputation: 11231
Yeah this works.
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
case 0:
return UITableViewCellEditingStyleNone;
break;
case 1:
return UITableViewCellEditingStyleDelete;
break;
default:
return UITableViewCellEditingStyleNone;
break;
}
}
Upvotes: 1
Reputation: 22395
Have you tried setting the tableViewCells editing style to none for the first section cells? I think that should work for you
Upvotes: 0