tags:

views:

113

answers:

2

Hello,

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.

A: 

Have you tried setting the tableViewCells editing style to none for the first section cells? I think that should work for you

Daniel
Well I did set the editing=false but editingStyle is readonly property.
rkb
use - (id)initWithStyle:(UITableViewCellStyle)stylereuseIdentifier:(NSString *)reuseIdentifier
Daniel
though i might be wrong, I dont have code in front of me so i dont recall that well, I think the answer below me has it right...
Daniel
+1  A: 

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;

    }
}
rkb